結果

問題 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
コンパイル時間 256 ms
コンパイル使用メモリ 32,728 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 22:09:37
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 34 ms
4,376 KB
testcase_04 AC 170 ms
4,376 KB
testcase_05 AC 146 ms
4,376 KB
testcase_06 AC 135 ms
4,380 KB
testcase_07 AC 152 ms
4,376 KB
testcase_08 AC 135 ms
4,380 KB
testcase_09 AC 134 ms
4,376 KB
testcase_10 AC 85 ms
4,380 KB
testcase_11 AC 42 ms
4,376 KB
testcase_12 AC 100 ms
4,376 KB
testcase_13 AC 59 ms
4,380 KB
testcase_14 AC 117 ms
4,376 KB
testcase_15 AC 43 ms
4,376 KB
testcase_16 AC 140 ms
4,376 KB
testcase_17 AC 59 ms
4,376 KB
testcase_18 AC 119 ms
4,376 KB
testcase_19 AC 91 ms
4,376 KB
testcase_20 AC 135 ms
4,380 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