結果

問題 No.2695 Warp Zone
ユーザー titiatitia
提出日時 2024-03-22 23:01:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 74,800 KB
最終ジャッジ日時 2024-03-22 23:01:31
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 WA -
testcase_02 AC 39 ms
53,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 49 ms
61,832 KB
testcase_09 AC 88 ms
74,440 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 37 ms
53,460 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 86 ms
73,004 KB
testcase_24 AC 38 ms
53,460 KB
testcase_25 AC 38 ms
53,460 KB
testcase_26 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter

H,W,N=map(int,input().split())
WA=[list(map(int,input().split())) for i in range(N)]

WA=[[1,1,1,1]]+WA+[[H,W,H,W]]

DP=[1<<63]*len(WA)
WA.sort(key=itemgetter(0))
WA.sort(key=itemgetter(1))

DP[0]=0


for i in range(len(WA)):
    now=DP[i]
    a,b,c,d=WA[i]
    for j in range(len(WA)):
        e,f,g,h=WA[j]

        if a<=e and b<=f:
            dis=(e-a)+(f-b)

            DP[j]=min(DP[j],DP[i]+dis)

        if c<=e and d<=f:
            dis=(e-c)+(f-d)

            DP[j]=min(DP[j],DP[i]+dis+1)

print(DP[-1])
0