結果

問題 No.612 Move on grid
ユーザー tsutajtsutaj
提出日時 2017-11-30 00:23:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,500 ms
コード長 760 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 33,404 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-10 03:42:11
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 36 ms
5,376 KB
testcase_04 AC 170 ms
5,376 KB
testcase_05 AC 148 ms
5,376 KB
testcase_06 AC 140 ms
5,376 KB
testcase_07 AC 157 ms
5,376 KB
testcase_08 AC 141 ms
5,376 KB
testcase_09 AC 140 ms
5,376 KB
testcase_10 AC 88 ms
5,376 KB
testcase_11 AC 44 ms
5,376 KB
testcase_12 AC 105 ms
5,376 KB
testcase_13 AC 62 ms
5,376 KB
testcase_14 AC 123 ms
5,376 KB
testcase_15 AC 46 ms
5,376 KB
testcase_16 AC 149 ms
5,376 KB
testcase_17 AC 62 ms
5,376 KB
testcase_18 AC 124 ms
5,376 KB
testcase_19 AC 95 ms
5,376 KB
testcase_20 AC 139 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>

const int MOD = 1000000007;
const int SEG = 20000;
int T, a, b, c, d, e;
int dp[2][SEG + 10];

int main() {
    scanf("%d%d%d%d%d%d", &T, &a, &b, &c, &d, &e);

    dp[0][SEG / 2] = 1;
    for(int i=0; i<T; i++) {
        int mo = i % 2;
        for(int j=0; j<=SEG; j++) {
            int array[] = {-a, a, -b, b, -c, c};
            for(int k=0; k<6; k++) {
                int npos = j + array[k];
                if(npos < 0 || npos > SEG) continue;
                (dp[mo^1][npos] += dp[mo][j]) %= MOD;
            }
        }
        memset(dp[mo], 0, sizeof(dp[mo]));
    }

    int ans = 0;
    for(int i=d+SEG/2; i<=e+SEG/2; i++) {
        (ans += dp[T%2][i]) %= MOD;
    }
    printf("%d\n", ans);
    return 0;
}
0