結果
問題 | No.20 砂漠のオアシス |
ユーザー | tnodino |
提出日時 | 2022-02-11 06:31:25 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 918 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 87,040 KB |
実行使用メモリ | 83,876 KB |
最終ジャッジ日時 | 2023-09-09 06:47:51 |
合計ジャッジ時間 | 3,983 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
71,672 KB |
testcase_01 | AC | 91 ms
71,476 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 117 ms
77,984 KB |
testcase_05 | AC | 189 ms
80,832 KB |
testcase_06 | WA | - |
testcase_07 | AC | 237 ms
83,876 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 90 ms
71,824 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 119 ms
77,992 KB |
testcase_15 | AC | 115 ms
77,856 KB |
testcase_16 | AC | 123 ms
77,988 KB |
testcase_17 | WA | - |
testcase_18 | AC | 124 ms
78,052 KB |
testcase_19 | WA | - |
testcase_20 | AC | 107 ms
77,728 KB |
ソースコード
from collections import deque def bfs(H, W, L, sx, sy, gx, gy, V, Ox, Oy): def _bfs(): while Queue: x,y = Queue.popleft() for i in range(len(dx)): nx,my = x + dx[i], y + dy[i] if nx < 0 or H <= nx or my < 0 or W <= my: continue if Cost[nx][my] < Cost[x][y] - L[nx][my]: Cost[nx][my] = Cost[x][y] - L[nx][my] Queue.append((nx, my)) INF = -10 dx = [0, 0, -1, 1] dy = [-1, 1, 0, 0] Cost = [[INF] * W for _ in range(H)] Cost[sx][sy] = V Queue = deque() Queue.append((sx, sy)) _bfs() Cost[Ox][Oy] *= 2 Queue.append((Ox, Oy)) _bfs() return Cost[gx][gy] N,V,Ox,Oy = map(int,input().split()) L = [list(map(int,input().split())) for _ in range(N)] if bfs(N, N, L, 0, 0, N-1, N-1, V, Ox-1, Oy-1): print('YES') else: print('NO')