結果

問題 No.2695 Warp Zone
ユーザー tkykwtnbtkykwtnb
提出日時 2024-03-23 14:23:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 278,804 KB
最終ジャッジ日時 2024-03-23 14:23:31
合計ジャッジ時間 4,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,916 KB
testcase_01 WA -
testcase_02 AC 29 ms
10,112 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(defaultdict)
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)
        G[(a,b)][(c,d)]=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)]=tmp
            Q.append((c,d))
print(C[(H,W)])
0