結果

問題 No.20 砂漠のオアシス
ユーザー convexineqconvexineq
提出日時 2021-01-17 02:22:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 81,796 KB
最終ジャッジ日時 2023-08-19 06:44:43
合計ジャッジ時間 4,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,152 KB
testcase_01 AC 73 ms
71,144 KB
testcase_02 AC 70 ms
70,956 KB
testcase_03 WA -
testcase_04 AC 108 ms
77,640 KB
testcase_05 AC 257 ms
81,796 KB
testcase_06 AC 212 ms
79,064 KB
testcase_07 AC 200 ms
78,960 KB
testcase_08 AC 204 ms
79,084 KB
testcase_09 AC 207 ms
78,772 KB
testcase_10 AC 67 ms
70,840 KB
testcase_11 AC 66 ms
71,148 KB
testcase_12 AC 99 ms
77,448 KB
testcase_13 AC 104 ms
77,248 KB
testcase_14 AC 112 ms
77,700 KB
testcase_15 AC 105 ms
77,388 KB
testcase_16 AC 119 ms
78,304 KB
testcase_17 AC 113 ms
77,756 KB
testcase_18 WA -
testcase_19 AC 121 ms
78,200 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 and dijkstra(sx,sy,0)) else "NO")
0