結果

問題 No.612 Move on grid
ユーザー face4face4
提出日時 2019-12-15 16:41:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,500 ms
コード長 755 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 70,560 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 15:35:34
合計ジャッジ時間 3,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 25 ms
4,380 KB
testcase_04 AC 97 ms
4,380 KB
testcase_05 AC 97 ms
4,380 KB
testcase_06 AC 97 ms
4,376 KB
testcase_07 AC 97 ms
4,376 KB
testcase_08 AC 97 ms
4,380 KB
testcase_09 AC 96 ms
4,380 KB
testcase_10 AC 61 ms
4,380 KB
testcase_11 AC 30 ms
4,376 KB
testcase_12 AC 72 ms
4,376 KB
testcase_13 AC 41 ms
4,380 KB
testcase_14 AC 84 ms
4,376 KB
testcase_15 AC 31 ms
4,376 KB
testcase_16 AC 95 ms
4,376 KB
testcase_17 AC 43 ms
4,376 KB
testcase_18 AC 86 ms
4,376 KB
testcase_19 AC 67 ms
4,380 KB
testcase_20 AC 91 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define inRange(x,a,b) (a <= x && x < b)

int main(){
    int t, a[3], d, e;
    cin >> t >> a[0] >> a[1] >> a[2] >> d >> e;
    vector<int> dp(20001, 0);
    dp[10000] = 1;
    while(t-- > 0){
        vector<int> ndp(20001, 0);
        for(int i = 0; i < 3; i++){
            for(int j : {-1, 1}){
                for(int k = 0; k <= 20000; k++){
                    if(inRange(k+j*a[i], 0, 20001)){
                        (ndp[k+j*a[i]] += dp[k]) %= mod;
                    }
                }
            }
        }
        dp = ndp;
    }
    int ans = 0;
    for(int i = d+10000; i <= e+10000; i++) (ans += dp[i]) %= mod;
    cout << ans << endl;
    return 0;
}
0