結果
| 問題 | No.20 砂漠のオアシス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 14:23:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 903 bytes |
| コンパイル時間 | 95 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 19,320 KB |
| 最終ジャッジ日時 | 2024-07-19 16:06:46 |
| 合計ジャッジ時間 | 4,448 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 5 |
ソースコード
from heapq import heappush, heappop
from collections import defaultdict
N, V, X, Y = map(int, input().split())
X -= 1
Y -= 1
L = [list(map(int, input().split())) for _ in range(N)]
que = [(-V, 0, 0, False)] # life, x, y, usedO
maxLife = defaultdict(lambda : -float('inf'))
while que:
life, x, y, usedO = heappop(que)
life *= -1
if x == X and y == Y and not usedO:
life *= 2
usedO = True
if life <= 0:
continue
if x == y == N - 1:
print('YES')
exit()
if maxLife[(x, y, usedO)] >= life:
continue
maxLife[(x, y, usedO)] = life
for nx in [x - 1, x + 1]:
if 0 <= nx < N and life - L[nx][y] > 0:
heappush(que, (-(life - L[nx][y]), nx, y, usedO))
for ny in [y - 1, y + 1]:
if 0 <= ny < N and life - L[x][ny] > 0:
heappush(que, (-(life - L[x][ny]), x, ny, usedO))
print('NO')