結果
問題 | No.20 砂漠のオアシス |
ユーザー | yaoshimax |
提出日時 | 2015-02-10 23:39:37 |
言語 | Python2 (2.7.18) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 732 ms |
コンパイル使用メモリ | 6,536 KB |
実行使用メモリ | 9,764 KB |
最終ジャッジ日時 | 2023-08-03 07:25:49 |
合計ジャッジ時間 | 6,645 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
6,052 KB |
testcase_01 | AC | 14 ms
6,064 KB |
testcase_02 | AC | 13 ms
6,164 KB |
testcase_03 | AC | 33 ms
6,352 KB |
testcase_04 | AC | 56 ms
6,364 KB |
testcase_05 | AC | 819 ms
9,764 KB |
testcase_06 | AC | 765 ms
8,812 KB |
testcase_07 | AC | 768 ms
8,732 KB |
testcase_08 | AC | 769 ms
8,696 KB |
testcase_09 | AC | 766 ms
8,632 KB |
testcase_10 | WA | - |
testcase_11 | AC | 12 ms
6,256 KB |
testcase_12 | WA | - |
testcase_13 | AC | 45 ms
6,316 KB |
testcase_14 | AC | 74 ms
6,336 KB |
testcase_15 | AC | 58 ms
6,232 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 157 ms
6,712 KB |
testcase_20 | AC | 28 ms
6,260 KB |
ソースコード
from heapq import heappush, heappop N,V,Ox,Oy=map(int,raw_input().split()) L=[[0 for i in range(N)] for j in range(N)] for i in range(N): L[i] = map(int,raw_input().split()) P=[[-1 for i in range(N)] for j in range(N)] pq=[] heappush(pq,(0,0,0)) d1 = [1,0,-1,0] d2 = [0,1,0,-1] while len(pq) != 0: dist,x,y = heappop(pq) if P[x][y] != -1: continue P[x][y]=dist for dx,dy in zip(d1,d2): nx = x+dx ny = y+dy; if nx>=0 and ny >= 0 and nx <N and ny <N: heappush(pq,(dist+L[nx][ny],nx,ny)) P2=[[-1 for i in range(N)] for j in range(N)] pq2=[] Ox-=1 Oy-=1 if Ox >= 0 and Oy >= 0 and Ox <N and Oy <N: heappush(pq2,(0,Ox,Oy)) while len(pq2)!=0: dist,x,y = heappop(pq2) if P2[x][y] != -1: continue P2[x][y]=dist for dx,dy in zip(d1,d2): nx = x+dx ny = y+dy; if nx>=0 and ny >= 0 and nx <N and ny <N: heappush(pq2,(dist+L[nx][ny],nx,ny)) #print P[N-1][N-1], P[Ox][Oy], P2[N-1][N-1] if P[N-1][N-1] < V: #print P[N-1][N-1] print "YES" elif P2[N-1][N-1]!=-1 and 2*(V-P[Ox][Oy])-P2[N-1][N-1] > 0: #print P[Ox][Oy], ",", P2[N-1][N-1] print "YES" else: print "NO"