結果
問題 | No.20 砂漠のオアシス |
ユーザー | ytft |
提出日時 | 2022-11-03 17:06:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,310 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 87,296 KB |
実行使用メモリ | 107,600 KB |
最終ジャッジ日時 | 2023-09-25 01:35:05 |
合計ジャッジ時間 | 8,313 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,308 KB |
testcase_01 | AC | 86 ms
76,152 KB |
testcase_02 | AC | 77 ms
75,816 KB |
testcase_03 | AC | 162 ms
80,324 KB |
testcase_04 | AC | 155 ms
80,000 KB |
testcase_05 | AC | 1,041 ms
107,600 KB |
testcase_06 | AC | 869 ms
103,296 KB |
testcase_07 | AC | 882 ms
103,900 KB |
testcase_08 | AC | 522 ms
101,048 KB |
testcase_09 | AC | 861 ms
103,804 KB |
testcase_10 | WA | - |
testcase_11 | AC | 76 ms
71,412 KB |
testcase_12 | AC | 214 ms
80,264 KB |
testcase_13 | AC | 210 ms
81,048 KB |
testcase_14 | AC | 227 ms
81,860 KB |
testcase_15 | AC | 220 ms
81,232 KB |
testcase_16 | AC | 288 ms
83,364 KB |
testcase_17 | AC | 262 ms
82,180 KB |
testcase_18 | AC | 273 ms
83,044 KB |
testcase_19 | AC | 295 ms
83,800 KB |
testcase_20 | WA | - |
ソースコード
import sys,heapq input=lambda:sys.stdin.readline().rstrip() class node: def __init__(self,con): self.con=con class directedWeightedGraph: def __init__(self,N,edges=[]): self.N=N self.nodes=[node([]) for i in range(N)] for i in edges: self.nodes[i[0]].append(i[1:]) def connect(self,f,t,weight=0): self.nodes[f].con.append([t,weight]) def dijkstra(self,start): ans=[float('inf') for i in range(self.N)] watch=[] heapq.heappush(watch, [0,start]) while watch: cur=heapq.heappop(watch) if ans[cur[1]]==float('inf'): ans[cur[1]]=cur[0] for i in self.nodes[cur[1]].con: heapq.heappush(watch,[i[1]+ans[cur[1]],i[0]]) return ans O=[] N,V,*O=map(int,input().split()) O[0],O[1]=O[1]-1,O[0]-1 L=[list(map(int,input().split())) for i in range(N)] G=directedWeightedGraph(N**2) for i in range(N-1): for j in range(N): G.connect(i*N+j,i*N+j+N,L[i+1][j]) G.connect(i*N+j+N,i*N+j,L[i][j]) G.connect(j*N+i+1,j*N+i,L[j][i]) G.connect(j*N+i,j*N+i+1,L[j][i+1]) A=G.dijkstra(0) if A[N**2-1]<V: print('YES') elif O[0]>-1 and V>A[O[0]*N+O[1]]: print(['NO','YES'][G.dijkstra(N**2-1)[O[0]*N+O[1]]<(V-A[O[0]*N+O[1]])*2]) else: print('NO')