結果

問題 No.612 Move on grid
ユーザー ミドリムシ
提出日時 2018-04-21 16:06:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 161 ms / 2,500 ms
コード長 1,166 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 72,796 KB
実行使用メモリ 42,752 KB
最終ジャッジ日時 2024-06-27 05:24:05
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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