結果

問題 No.612 Move on grid
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-06-05 17:04:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 888 ms / 2,500 ms
コード長 750 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 150,188 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 22:27:27
合計ジャッジ時間 14,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 13 ms
4,380 KB
testcase_03 AC 211 ms
4,376 KB
testcase_04 AC 870 ms
4,376 KB
testcase_05 AC 887 ms
4,380 KB
testcase_06 AC 886 ms
4,380 KB
testcase_07 AC 874 ms
4,376 KB
testcase_08 AC 888 ms
4,380 KB
testcase_09 AC 879 ms
4,380 KB
testcase_10 AC 551 ms
4,380 KB
testcase_11 AC 260 ms
4,380 KB
testcase_12 AC 657 ms
4,380 KB
testcase_13 AC 369 ms
4,376 KB
testcase_14 AC 767 ms
4,376 KB
testcase_15 AC 283 ms
4,376 KB
testcase_16 AC 874 ms
4,376 KB
testcase_17 AC 381 ms
4,376 KB
testcase_18 AC 785 ms
4,376 KB
testcase_19 AC 603 ms
4,380 KB
testcase_20 AC 825 ms
4,376 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 <= 20180;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