結果
| 問題 |
No.20 砂漠のオアシス
|
| コンテスト | |
| ユーザー |
Tawara
|
| 提出日時 | 2015-12-30 02:28:02 |
| 言語 | Python2 (2.7.18) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 543 bytes |
| コンパイル時間 | 92 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 9,652 KB |
| 最終ジャッジ日時 | 2024-10-13 05:31:12 |
| 合計ジャッジ時間 | 2,739 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 7 |
ソースコード
from heapq import heappop,heappush I=lambda:map(int,raw_input().split()) N,V,x,y=I();s=(0,0);o=(x-1,y-1);g=(N-1,N-1) L=[I()for i in range(N)];dxy=((1,0),(0,1),(-1,0),(0,-1)) def d(s,g): Q=[];D=[N*[100000]for i in range(N)] D[s[1]][s[0]]=0 heappush(Q,(0,(0,0))) while Q: c,h=heappop(Q) if h == g:break for dx,dy in dxy: nx=h[0]+dx;ny=h[1]+dy if 0<=nx<N and 0<=ny<N and c+L[ny][nx]<D[ny][nx]: D[ny][nx]=nc=c+L[ny][nx];heappush(Q,(nc,(nx,ny))) return D[g[1]][g[0]] print["NO","YES"][V>d(s,g)or(x*y!=0 and(V-d(s,o))*2>d(o,g))]
Tawara