結果

問題 No.612 Move on grid
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-06-05 17:02:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 756 bytes
コンパイル時間 3,718 ms
コンパイル使用メモリ 149,992 KB
実行使用メモリ 12,624 KB
最終ジャッジ日時 2023-09-12 22:26:33
合計ジャッジ時間 8,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
12,624 KB
testcase_01 AC 56 ms
6,084 KB
testcase_02 AC 111 ms
6,076 KB
testcase_03 AC 2,074 ms
6,164 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 T;
i64 a,b,c,d,e;

vector<i64> dp[2];

i64 MOD = 1e9 + 7;

int main(){
  dp[0].resize(202020,0);
  dp[1].resize(202020,0);
  cin >> T >> a >> b >> c >> d >> e;
  dp[0][101010] = 1;
  d += 101010;
  e += 101010;
  vector<i64> dd = {a,b,c,-a,-b,-c};
  for(int c = 1;c <= T;c++){
    auto& before = dp[0];
    auto& next = dp[1];
    next.assign(202020,0);
    for(int i = 0;i < 200020;i++){
      for(auto j : dd){
        if(i - j >= 0) next[i] = (next[i] + before[i - j]) % MOD;
      }
    }
    swap(next,before);
  }
  i64 ans = 0;
  for(int i = d;i <= e;i++){
    ans = (ans + dp[0][i]) % MOD;
  }
  cout << ans << endl;
}
0