結果
問題 | No.20 砂漠のオアシス |
ユーザー | yaoshimax |
提出日時 | 2015-02-10 23:39:37 |
言語 | Python2 (2.7.18) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 192 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 10,408 KB |
最終ジャッジ日時 | 2024-04-21 06:23:02 |
合計ジャッジ時間 | 6,304 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
6,656 KB |
testcase_01 | AC | 14 ms
6,528 KB |
testcase_02 | AC | 15 ms
6,528 KB |
testcase_03 | AC | 35 ms
6,784 KB |
testcase_04 | AC | 57 ms
6,784 KB |
testcase_05 | AC | 851 ms
10,408 KB |
testcase_06 | AC | 794 ms
9,216 KB |
testcase_07 | AC | 796 ms
9,216 KB |
testcase_08 | AC | 790 ms
9,216 KB |
testcase_09 | AC | 794 ms
9,216 KB |
testcase_10 | WA | - |
testcase_11 | AC | 12 ms
6,656 KB |
testcase_12 | WA | - |
testcase_13 | AC | 47 ms
6,528 KB |
testcase_14 | AC | 77 ms
6,656 KB |
testcase_15 | AC | 59 ms
6,784 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 161 ms
7,040 KB |
testcase_20 | AC | 28 ms
6,656 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"