結果
問題 | No.20 砂漠のオアシス |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-12-31 09:52:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 246 ms / 5,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 86,144 KB |
最終ジャッジ日時 | 2024-10-07 23:47:14 |
合計ジャッジ時間 | 3,219 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
from collections import dequen,v,y,x = map(int,input().split())L = [list(map(int,input().split())) for i in range(n)]inf = 10**10def bfs(sx,sy):dis = [[inf]*n for i in range(n)]dis[sx][sy] = 0q = deque([[sx,sy]])while q:nx,ny = q.popleft()for (i,j) in ((1,0),(-1,0),(0,1),(0,-1)):nnx = nx+inny = ny+jif 0 <= nnx < n and 0 <= nny < n and dis[nnx][nny] > dis[nx][ny]+L[nnx][nny]:dis[nnx][nny] = dis[nx][ny]+L[nnx][nny]q.append([nnx,nny])return disdis0 = bfs(0,0)diso = bfs(x-1,y-1)ans = "NO"if dis0[-1][-1] < v:ans = "YES"if x > 0 and diso[-1][-1] < (v-dis0[x-1][y-1])*2:ans = "YES"print(ans)