結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-21 16:06:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 160 ms / 2,500 ms |
| コード長 | 1,166 bytes |
| 記録 | |
| コンパイル時間 | 559 ms |
| コンパイル使用メモリ | 70,328 KB |
| 実行使用メモリ | 42,756 KB |
| 最終ジャッジ日時 | 2025-12-05 13:18:14 |
| 合計ジャッジ時間 | 2,791 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#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;
}