結果

問題 No.612 Move on grid
ユーザー kurarrrkurarrr
提出日時 2018-02-23 15:08:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,207 ms / 2,500 ms
コード長 1,321 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 169,836 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-16 22:24:37
合計ジャッジ時間 18,383 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 60 ms
5,376 KB
testcase_04 AC 67 ms
5,376 KB
testcase_05 AC 2,207 ms
5,888 KB
testcase_06 AC 2,166 ms
6,016 KB
testcase_07 AC 31 ms
5,376 KB
testcase_08 AC 2,177 ms
5,888 KB
testcase_09 AC 828 ms
5,376 KB
testcase_10 AC 637 ms
5,376 KB
testcase_11 AC 151 ms
5,376 KB
testcase_12 AC 1,166 ms
5,376 KB
testcase_13 AC 346 ms
5,376 KB
testcase_14 AC 1,607 ms
5,504 KB
testcase_15 AC 187 ms
5,376 KB
testcase_16 AC 1,835 ms
5,632 KB
testcase_17 AC 158 ms
5,376 KB
testcase_18 AC 1,463 ms
5,376 KB
testcase_19 AC 356 ms
5,376 KB
testcase_20 AC 497 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

map<int,ll> now,nxt;

void update(int f,ll x){
  if(nxt.count(f)){
    (nxt[f] += x) %= lmod;
  }else{
    nxt[f] = x;
  }
}

int main(){
  int T,a,b,c,d,e,f,g;
  cin >> T;
  cin >> a >> b >> c >> d >> e;
  now[0] = 1;
  rep(i,T){
    nxt.clear();
    for(auto u:now){
      tie(f,g) = u;
      update(f+a,g);
      update(f+b,g);
      update(f+c,g);
      update(f-a,g);
      update(f-b,g);
      update(f-c,g);
    }
    swap(now,nxt);
  }
  ll ans = 0LL;
  for(auto u:now){
    tie(f,g) = u;
    if(f>=d && f<=e) (ans += g) %= lmod;
  }
  cout << ans << endl;
  return 0;
}
0