結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
53,632 KB
testcase_01 AC 57 ms
61,568 KB
testcase_02 AC 56 ms
61,056 KB
testcase_03 AC 71 ms
68,864 KB
testcase_04 AC 86 ms
74,112 KB
testcase_05 AC 241 ms
85,632 KB
testcase_06 AC 247 ms
85,888 KB
testcase_07 AC 247 ms
86,528 KB
testcase_08 AC 226 ms
84,352 KB
testcase_09 AC 209 ms
82,944 KB
testcase_10 WA -
testcase_11 AC 47 ms
53,760 KB
testcase_12 WA -
testcase_13 AC 77 ms
70,528 KB
testcase_14 AC 93 ms
76,288 KB
testcase_15 AC 82 ms
72,320 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 99 ms
77,184 KB
testcase_20 AC 73 ms
67,456 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 x > 0 and diso[-1][-1] < (v-dis0[x-1][y-1])*2:
    ans = "YES" 
print(ans) 
0