結果
問題 | No.20 砂漠のオアシス |
ユーザー | tnodino |
提出日時 | 2022-02-11 06:30:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 923 bytes |
コンパイル時間 | 359 ms |
コンパイル使用メモリ | 87,004 KB |
実行使用メモリ | 83,732 KB |
最終ジャッジ日時 | 2023-09-09 06:46:41 |
合計ジャッジ時間 | 4,216 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 90 ms
71,760 KB |
testcase_01 | AC | 92 ms
71,568 KB |
testcase_02 | AC | 96 ms
71,316 KB |
testcase_03 | AC | 118 ms
77,984 KB |
testcase_04 | AC | 119 ms
78,060 KB |
testcase_05 | AC | 190 ms
80,568 KB |
testcase_06 | AC | 119 ms
77,948 KB |
testcase_07 | AC | 236 ms
83,732 KB |
testcase_08 | AC | 142 ms
78,880 KB |
testcase_09 | AC | 175 ms
80,352 KB |
testcase_10 | WA | - |
testcase_11 | AC | 92 ms
71,652 KB |
testcase_12 | WA | - |
testcase_13 | AC | 109 ms
77,476 KB |
testcase_14 | AC | 118 ms
77,648 KB |
testcase_15 | AC | 116 ms
77,520 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 123 ms
77,552 KB |
testcase_20 | AC | 108 ms
77,640 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) >= 0: print('YES') else: print('NO')