結果

問題 No.612 Move on grid
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-06-05 17:03:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 1,274 ms
コンパイル使用メモリ 150,436 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 22:26:52
合計ジャッジ時間 14,015 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 12 ms
4,376 KB
testcase_03 AC 209 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 879 ms
4,376 KB
testcase_09 AC 870 ms
4,380 KB
testcase_10 AC 544 ms
4,380 KB
testcase_11 AC 257 ms
4,380 KB
testcase_12 AC 651 ms
4,380 KB
testcase_13 AC 364 ms
4,380 KB
testcase_14 AC 758 ms
4,380 KB
testcase_15 AC 280 ms
4,376 KB
testcase_16 AC 864 ms
4,380 KB
testcase_17 AC 377 ms
4,376 KB
testcase_18 AC 777 ms
4,376 KB
testcase_19 AC 595 ms
4,376 KB
testcase_20 AC 816 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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(20202,0);
  dp[1].resize(20202,0);
  cin >> T >> a >> b >> c >> d >> e;
  dp[0][10101] = 1;
  d += 10101;
  e += 10101;
  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(20202,0);
    for(int i = 0;i < 20002;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