結果

問題 No.2695 Warp Zone
ユーザー tkykwtnbtkykwtnb
提出日時 2024-03-23 12:01:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 557 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 588,436 KB
最終ジャッジ日時 2024-03-23 12:01:48
合計ジャッジ時間 4,369 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,788 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
H,W,N=map(int,input().split())
WARP={}
for _ in range(N):
    a,b,c,d=map(int,input().split())
    a-=1;b-=1;c-=1;d-=1
    WARP[(a,b)]=(c,d)
G=[[10**10 for _ in range(W)] for _ in range(H)]
Q=deque([])
Q.append(((0,0),0))
while Q:
    (h,w),c=Q.popleft()
    c=min(c,G[h][w])
    G[h][w]=c
    if h+1<H and c+1<G[h+1][w]:Q.append(((h+1,w),c+1))
    if w+1<W and c+1<G[h][w+1]:Q.append(((h,w+1),c+1))
    if (h,w) in WARP.keys():
        nh,nw=WARP[(h,w)]
        if c+1<G[nh][nw]:Q.append((WARP[(h,w)],c+1))
print(G[H-1][W-1])
0