結果

問題 No.2695 Warp Zone
ユーザー tkykwtnbtkykwtnb
提出日時 2024-03-23 14:12:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 149,012 KB
最終ジャッジ日時 2024-03-23 14:12:58
合計ジャッジ時間 3,957 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,788 KB
testcase_01 AC 29 ms
9,984 KB
testcase_02 AC 30 ms
9,984 KB
testcase_03 TLE -
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 #

H,W,N=map(int,input().split())
from collections import defaultdict,deque
G=defaultdict(dict)
C=defaultdict(int)
I=[]
O=[]
G[(1,1)][(H,W)]=H-1+W-1
for _ in range(N):
    a,b,c,d=map(int,input().split())
    G[(1,1)][(a,b)]=a-1+b-1
    G[(1,1)][(c,d)]=c-1+d-1
    G[(a,b)][(c,d)]=1
    G[(a,b)][(H,W)]=H-a+H-b
    G[(c,d)][(H,W)]=H-c+W-d
    C[(a,b)]=1<<60
    C[(c,d)]=1<<60
    I.append((a,b))
    O.append((c,d))
for c,d in O:
    for a,b in I:
        G[(c,d)][(a,b)]=abs(c-a)+abs(d-b)
C[(H,W)]=1<<60
C[(1,1)]=0
Q=deque()
Q.append((1,1))
while Q:
    a,b=Q.popleft()
    for c,d in G[(a,b)].keys():
        tmp=C[(a,b)]+G[(a,b)][(c,d)]
        if tmp<C[(c,d)]:
            C[(c,d)]=min(C[(c,d)],tmp)
            Q.append((c,d))
print(C[(H,W)])
0