結果

問題 No.612 Move on grid
ユーザー ミドリムシミドリムシ
提出日時 2018-04-21 16:06:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,500 ms
コード長 1,166 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 72,440 KB
実行使用メモリ 42,780 KB
最終ジャッジ日時 2023-09-09 12:19:12
合計ジャッジ時間 3,494 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
42,420 KB
testcase_01 AC 12 ms
42,424 KB
testcase_02 AC 12 ms
42,728 KB
testcase_03 AC 16 ms
42,424 KB
testcase_04 AC 25 ms
42,780 KB
testcase_05 AC 137 ms
42,512 KB
testcase_06 AC 144 ms
42,504 KB
testcase_07 AC 18 ms
42,452 KB
testcase_08 AC 143 ms
42,460 KB
testcase_09 AC 60 ms
42,564 KB
testcase_10 AC 50 ms
42,440 KB
testcase_11 AC 22 ms
42,424 KB
testcase_12 AC 81 ms
42,424 KB
testcase_13 AC 32 ms
42,480 KB
testcase_14 AC 105 ms
42,508 KB
testcase_15 AC 23 ms
42,476 KB
testcase_16 AC 109 ms
42,452 KB
testcase_17 AC 26 ms
42,556 KB
testcase_18 AC 97 ms
42,496 KB
testcase_19 AC 39 ms
42,496 KB
testcase_20 AC 53 ms
42,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int T, a, b, c, d, e;

int dp[500][20010];

long move(int now_time, int now_position){
    if(now_time == T){
        return d <= now_position && now_position <= e;
    }else if(dp[now_time][now_position + 10005] != -1){
        return dp[now_time][now_position + 10005];
    }else{
        return dp[now_time][now_position + 10005] = (move(now_time + 1, now_position + a) + 
                                                     move(now_time + 1, now_position + b) +
                                                     move(now_time + 1, now_position + c) +
                                                     move(now_time + 1, now_position - a) +
                                                     move(now_time + 1, now_position - b) +
                                                     move(now_time + 1, now_position - c)) % long(1e9 + 7);
    }
}

int main(){
    cin >> T >> a >> b >> c >> d >> e;
    for(int i = 0; i < 500; i++){
        for(int j = 0; j < 20010; j++){
            dp[i][j] = -1;
        }
    }
    cout << move(0, 0) << endl;
}
0