結果

問題 No.20 砂漠のオアシス
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-12-31 09:49:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 86,272 KB
最終ジャッジ日時 2024-04-16 20:35:29
合計ジャッジ時間 3,573 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,632 KB
testcase_01 AC 56 ms
61,696 KB
testcase_02 AC 55 ms
61,568 KB
testcase_03 AC 69 ms
68,480 KB
testcase_04 AC 85 ms
74,240 KB
testcase_05 AC 246 ms
85,248 KB
testcase_06 AC 247 ms
86,016 KB
testcase_07 AC 244 ms
86,272 KB
testcase_08 AC 221 ms
84,352 KB
testcase_09 AC 209 ms
83,328 KB
testcase_10 WA -
testcase_11 AC 46 ms
53,888 KB
testcase_12 WA -
testcase_13 AC 76 ms
70,528 KB
testcase_14 AC 92 ms
76,416 KB
testcase_15 AC 81 ms
72,576 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 98 ms
76,800 KB
testcase_20 AC 72 ms
67,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,v,x,y = map(int,input().split())
L = [list(map(int,input().split())) for i in range(n)]
inf = 10**10

def bfs(sx,sy):
    dis = [[inf]*n for i in range(n)]
    dis[sx][sy] = 0
    q = deque([[sx,sy]])
    while q:
        nx,ny = q.popleft()
        for (i,j) in ((1,0),(-1,0),(0,1),(0,-1)):
            nnx = nx+i
            nny = ny+j
            if 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 dis


dis0 = bfs(0,0)
diso = bfs(x-1,y-1)
ans = "NO"
if dis0[-1][-1] < v:
    ans = "YES"

if diso[-1][-1] < (v-dis0[x-1][y-1])*2:
    ans = "YES" 
print(ans) 
0