結果
問題 | No.20 砂漠のオアシス |
ユーザー | convexineq |
提出日時 | 2021-01-17 02:23:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 705 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 87,120 KB |
実行使用メモリ | 82,144 KB |
最終ジャッジ日時 | 2023-08-19 06:45:09 |
合計ジャッジ時間 | 4,615 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,460 KB |
testcase_01 | AC | 72 ms
71,540 KB |
testcase_02 | AC | 70 ms
71,440 KB |
testcase_03 | AC | 110 ms
78,108 KB |
testcase_04 | AC | 105 ms
77,820 KB |
testcase_05 | AC | 262 ms
82,144 KB |
testcase_06 | AC | 214 ms
79,256 KB |
testcase_07 | AC | 214 ms
79,036 KB |
testcase_08 | AC | 216 ms
79,336 KB |
testcase_09 | AC | 221 ms
78,996 KB |
testcase_10 | AC | 71 ms
71,560 KB |
testcase_11 | AC | 70 ms
71,360 KB |
testcase_12 | AC | 105 ms
77,496 KB |
testcase_13 | AC | 109 ms
77,888 KB |
testcase_14 | AC | 118 ms
77,988 KB |
testcase_15 | AC | 111 ms
77,812 KB |
testcase_16 | AC | 126 ms
78,144 KB |
testcase_17 | AC | 120 ms
78,212 KB |
testcase_18 | WA | - |
testcase_19 | AC | 124 ms
78,524 KB |
testcase_20 | WA | - |
ソースコード
n,v,sy,sx = map(int,input().split()) b = [list(map(int,input().split())) for _ in range(n)] sx -= 1;sy -= 1 def dijkstra(x,y,flag): d = [[-1]*n for _ in range(n)] d[x][y] = 0 from heapq import heappush, heappop q = [(0,x,y)] while q: dv,x,y = heappop(q) for nx,ny in [(x+1,y),(x-1,y),(x,y-1),(x,y+1)]: if 0 <= nx < n and 0 <= ny < n and d[nx][ny]==-1: d[nx][ny] = dv + b[nx][ny] heappush(q,(dv + b[nx][ny],nx,ny)) if flag: return v > d[-1][-1] else: return v > d[0][0] + b[sx][sy] and (v - d[0][0] - b[sx][sy])*2 > d[-1][-1] print("YES" if dijkstra(0,0,1) or (sx>=0 and dijkstra(sx,sy,0)) else "NO")