結果
問題 | No.20 砂漠のオアシス |
ユーザー |
|
提出日時 | 2020-04-30 21:34:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,440 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,640 KB |
実行使用メモリ | 79,376 KB |
最終ジャッジ日時 | 2024-12-17 18:24:27 |
合計ジャッジ時間 | 3,378 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 7 |
ソースコード
import heapqN, V, Ox, Oy = map(int, input().split())Ox -= 1Oy -= 1L = [[int(j) for j in input().split()] for i in range(N)]already = [[False for i in range(N)] for j in range(N)]already[0][0] = Truequeue = []heapq.heappush(queue, (0, 0, 0))course = [(0, 1), (1, 0), (-1, 0), (0, -1)]s = 0while queue:tmp = heapq.heappop(queue)for i in course:y, x = tmp[1] + i[0], tmp[2] + i[1]if x < 0 or y < 0 or x >= N or y >= N:continueif already[y][x]:continueif (v := tmp[0] + L[y][x]) >= V:continuealready[y][x] = Trueheapq.heappush(queue, (v, y, x))if y == Oy and x == Ox:s = vif already[N - 1][N - 1]:print('YES')exit()if (Ox == -1 and Oy == -1) or not already[Oy][Ox]:print('NO')exit()already = [[False for i in range(N)] for j in range(N)]already[0][0] = Truealready[Oy][Ox] = Trues -= max(V - s, 0)heapq.heappush(queue, (s, 0, 0))while queue:tmp = heapq.heappop(queue)for i in course:y, x = tmp[1] + i[0], tmp[2] + i[1]if x < 0 or y < 0 or x >= N or y >= N:continueif already[y][x]:continueif (v := tmp[0] + L[y][x]) >= V:continuealready[y][x] = Trueheapq.heappush(queue, (v, y, x))if already[N - 1][N - 1]:print('YES')else:print('NO')