結果
問題 | No.20 砂漠のオアシス |
ユーザー | Navier_Boltzmann |
提出日時 | 2022-10-11 04:12:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,427 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 87,104 KB |
実行使用メモリ | 90,540 KB |
最終ジャッジ日時 | 2023-09-07 06:35:00 |
合計ジャッジ時間 | 5,985 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 106 ms
72,552 KB |
testcase_01 | AC | 105 ms
72,876 KB |
testcase_02 | AC | 104 ms
72,716 KB |
testcase_03 | AC | 184 ms
81,008 KB |
testcase_04 | AC | 169 ms
81,084 KB |
testcase_05 | AC | 235 ms
88,548 KB |
testcase_06 | AC | 314 ms
90,264 KB |
testcase_07 | AC | 313 ms
90,540 KB |
testcase_08 | AC | 234 ms
89,972 KB |
testcase_09 | AC | 318 ms
90,456 KB |
testcase_10 | WA | - |
testcase_11 | AC | 103 ms
72,736 KB |
testcase_12 | WA | - |
testcase_13 | AC | 188 ms
81,760 KB |
testcase_14 | AC | 209 ms
82,484 KB |
testcase_15 | AC | 196 ms
82,180 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 235 ms
83,112 KB |
testcase_20 | AC | 162 ms
80,360 KB |
ソースコード
from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,V,X,Y = map(int,input().split()) L = [list(map(int,input().split())) for _ in range(N)] M = N**2 e = [[] for _ in range(M)] def f(i,j): return N*i+j H = N W = N def nb(x,y): tmp = [] if x+1<H: tmp.append((x+1,y)) if x-1>=0: tmp.append((x-1,y)) if y+1<W: tmp.append((x,y+1)) if y-1>=0: tmp.append((x,y-1)) return tmp X -= 1 Y -= 1 for i in range(N): for j in range(N): x = f(i,j) for ix,iy in nb(i,j): e[x].append((f(ix,iy),L[ix][iy])) INF = (1<<30) def dijkstra(s,e): N = len(e) dist = [INF]*N dist[s]=0 h = [] heappush(h,(0,s)) while h: nw,v = heappop(h) if dist[v]!=nw: continue for iv,ic in e[v]: nc = ic + nw if nc < dist[iv]: dist[iv] = nc heappush(h,(nc,iv)) return dist D = dijkstra(0,e) if (X,Y)==(-1,-1): if D[-1]<=V: print('YES') else: print('NO') exit() if D[-1]<=V: print('YES') exit() oasis = f(X,Y) if D[oasis]>V: print('NO') exit() H = V - D[oasis] H *= 2 D =dijkstra(oasis,e) if D[-1]<=H: print('YES') else: print('NO')