結果
| 問題 | No.2695 Warp Zone | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2024-03-22 23:01:27 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 588 bytes | 
| コンパイル時間 | 272 ms | 
| コンパイル使用メモリ | 82,712 KB | 
| 実行使用メモリ | 75,688 KB | 
| 最終ジャッジ日時 | 2024-09-30 12:22:32 | 
| 合計ジャッジ時間 | 3,097 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 7 WA * 17 | 
ソースコード
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])
            
            
            
        