結果

問題 No.2695 Warp Zone
ユーザー ニックネームニックネーム
提出日時 2024-03-22 22:21:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 648 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 154,132 KB
最終ジャッジ日時 2024-03-22 22:21:54
合計ジャッジ時間 3,795 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
16,916 KB
testcase_01 AC 29 ms
10,112 KB
testcase_02 AC 30 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())
s = set()
abcd = [tuple(map(int,input().split())) for _ in range(n)]
for a,b,c,d in abcd: s |= {(a,b),(c,d)}
s = [(1,1)]+list(s)+[(h,w)]; m = len(s)
p = {v:i for i,v in enumerate(s)}
q = [[10**18]*m for _ in range(m)]
for a,b,c,d in abcd: q[p[(a,b)]][p[(c,d)]] = 1
for i in range(m):
    a,b = s[i]
    for j in range(m):
        c,d = s[j]
        q[i][j] = min(q[i][j],abs(a-c)+abs(b-d))
x = [0]+[10**18]*(m-1); f = [True]*m
for _ in range(m):
    z = 10**18; u = -1
    for i in range(m):
        if f[i] and x[i]<z: z = x[i]; u = i
    f[u] = False
    for v in range(m): x[v] = min(x[v],z+q[u][v])
print(x[-1])
0