結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-02-12 09:40:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,633 bytes |
| 記録 | |
| コンパイル時間 | 2,356 ms |
| コンパイル使用メモリ | 79,200 KB |
| 実行使用メモリ | 70,688 KB |
| 最終ジャッジ日時 | 2024-10-03 03:14:55 |
| 合計ジャッジ時間 | 9,514 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 15 |
ソースコード
import java.util.*;
public class Main {
static final int MOD = 1000000007;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int[] arr = new int[6];
int count = 0;
int max = 0;
for (int i = 0; i < 3; i++) {
arr[i] = sc.nextInt();
arr[i + 3] = -arr[i];
max = Math.max(max, Math.abs(arr[i]));
}
int d = sc.nextInt();
int e = sc.nextInt();
HashMap<Integer, Integer>[] maps = new HashMap[t + 1];
maps[0] = new HashMap<>();
maps[0].put(0, 1);
for (int i = 1; i <= t; i++) {
maps[i] = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : maps[i - 1].entrySet()) {
int x = entry.getKey();
int y = entry.getValue();
for (int z : arr) {
if (x + z + max * (t - i) < d) {
continue;
}
if (x + z - max * (t - i) > e) {
continue;
}
if (maps[i].containsKey(x + z)) {
maps[i].put(x + z, (maps[i].get(x + z) + y) % MOD);
} else {
maps[i].put(x + z, y);
}
}
}
}
int total = 0;
for (int i = d; i <= e; i++) {
if (maps[t].containsKey(i)) {
total += maps[t].get(i);
total %= MOD;
}
}
System.out.println(total);
}
}
htensai