結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-30 20:06:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 839 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,036 KB |
| 実行使用メモリ | 78,144 KB |
| 最終ジャッジ日時 | 2024-12-17 14:13:31 |
| 合計ジャッジ時間 | 4,280 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 4 |
ソースコード
N, V, Ox, Oy = map(int, input().split())
Ox -= 1
Oy -= 1
L = [[int(j) for j in input().split()] for i in range(N)]
memo = [[0 for i in range(N)] for j in range(N)]
memo[0][0] = V
course = [(1, 0), (0, 1), (-1, 0), (0, -1)]
stack = [(0, 0, V, True)]
while stack:
tmp = stack.pop()
for i in course:
y, x = tmp[0] + i[0], tmp[1] - i[1]
if x < 0 or x >= N or y < 0 or y >= N:
continue
v = tmp[2] - L[y][x]
if v <= memo[y][x]:
continue
if x == N - 1 and y == N - 1:
print('YES')
exit()
if y == Oy and x == Ox and tmp:
memo[y][x] = v * 2
stack.append((y, x, memo[y][x], False))
else:
memo[y][x] = v
stack.append((y, x, memo[y][x], tmp))
print('NO')