結果
問題 | No.612 Move on grid |
ユーザー | りあん |
提出日時 | 2017-11-23 04:01:24 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 65 ms / 2,500 ms |
コード長 | 870 bytes |
コンパイル時間 | 1,644 ms |
コンパイル使用メモリ | 169,016 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-22 22:08:14 |
合計ジャッジ時間 | 2,988 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 7 ms
4,380 KB |
testcase_04 | AC | 18 ms
4,380 KB |
testcase_05 | AC | 65 ms
4,380 KB |
testcase_06 | AC | 62 ms
4,376 KB |
testcase_07 | AC | 19 ms
4,376 KB |
testcase_08 | AC | 63 ms
4,376 KB |
testcase_09 | AC | 37 ms
4,376 KB |
testcase_10 | AC | 26 ms
4,380 KB |
testcase_11 | AC | 10 ms
4,380 KB |
testcase_12 | AC | 37 ms
4,376 KB |
testcase_13 | AC | 16 ms
4,376 KB |
testcase_14 | AC | 48 ms
4,376 KB |
testcase_15 | AC | 11 ms
4,376 KB |
testcase_16 | AC | 56 ms
4,380 KB |
testcase_17 | AC | 12 ms
4,380 KB |
testcase_18 | AC | 46 ms
4,376 KB |
testcase_19 | AC | 20 ms
4,380 KB |
testcase_20 | AC | 29 ms
4,376 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; const int M = 1000000007; int main() { int t, a, b, c, d, e; cin >> t >> a >> b >> c >> d >> e; const int m = 22000, s = 11000; vector<int> dp(m, 0); dp[s] = 1; for (int i = 0; i < t; ++i) { vector<int> nex(m, 0); for (int j = 0; j < m; ++j) { if (dp[j] > 0) { nex[j + a] = (nex[j + a] + dp[j]) % M; nex[j - a] = (nex[j - a] + dp[j]) % M; nex[j + b] = (nex[j + b] + dp[j]) % M; nex[j - b] = (nex[j - b] + dp[j]) % M; nex[j + c] = (nex[j + c] + dp[j]) % M; nex[j - c] = (nex[j - c] + dp[j]) % M; } } dp = nex; } int ans = 0; for (int i = s + d; i <= s + e; ++i) ans = (ans + dp[i]) % M; cout << ans << "\n"; return 0; }