結果
問題 | No.20 砂漠のオアシス |
ユーザー |
|
提出日時 | 2020-04-30 23:41:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,439 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 12,800 KB |
最終ジャッジ日時 | 2024-12-17 22:37:09 |
合計ジャッジ時間 | 2,626 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 6 |
ソースコード
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, (L[0][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 -= V - sheapq.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')