結果

問題 No.20 砂漠のオアシス
ユーザー convexineqconvexineq
提出日時 2021-01-17 02:15:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 82,356 KB
最終ジャッジ日時 2023-08-19 06:39:21
合計ジャッジ時間 5,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,588 KB
testcase_01 AC 78 ms
71,396 KB
testcase_02 AC 78 ms
71,360 KB
testcase_03 WA -
testcase_04 AC 113 ms
77,868 KB
testcase_05 AC 287 ms
82,356 KB
testcase_06 AC 230 ms
79,384 KB
testcase_07 WA -
testcase_08 AC 226 ms
79,192 KB
testcase_09 AC 228 ms
79,192 KB
testcase_10 AC 76 ms
71,536 KB
testcase_11 AC 76 ms
71,456 KB
testcase_12 AC 113 ms
77,832 KB
testcase_13 AC 123 ms
77,916 KB
testcase_14 AC 128 ms
77,688 KB
testcase_15 AC 122 ms
77,904 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 139 ms
78,156 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v,sx,sy = map(int,input().split())
b = [list(map(int,input().split())) for _ in range(n)]

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] + d[sx][sy] and (v - d[0][0] - d[sx][sy])*2 > d[-1][-1]

    return d            

print("YES" if dijkstra(0,0,1) or dijkstra(sx,sy,0) else "NO")
0