結果

問題 No.2695 Warp Zone
ユーザー nononnonon
提出日時 2024-03-22 22:17:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 214,420 KB
実行使用メモリ 24,320 KB
最終ジャッジ日時 2024-03-22 22:17:42
合計ジャッジ時間 3,904 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 17 ms
10,368 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,548 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 23 ms
13,312 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
template<typename T>
vector<T> dijkstra(vector<vector<pair<int,T>>>&g, const T INF, int s=0)
{
    int n=g.size();
    vector<T>dist(n,INF);
    dist[s]=0;
    priority_queue<pair<T,int>,vector<pair<T,int>>,greater<pair<T,int>>>q;
    q.push(make_pair(T(0),s));
    while(!q.empty())
    {
        auto[d,u]=q.top();
        q.pop();
        if(dist[u]<d)continue;
        for(auto[v,w]:g[u])
        {
            if(dist[v]>d+w)
            {
                dist[v]=d+w;
                q.push(make_pair(dist[v],v));
            }
        }
    }
    return dist;
}
int H,W,N,A[2020],B[2020];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>H>>W>>N;
    for(int i=0;i<N;i++)cin>>A[i]>>B[i]>>A[i+N]>>B[i+N];
    vector<vector<pair<int,long>>>G(2*N+2);
    for(int i=0;i<2*N;i++)for(int j=0;j<2*N;j++)if(i!=j)
    {
        if(i+N==j)G[i].push_back(make_pair(j,1));
        else if(A[i]<=A[j]&&B[i]<=B[j])G[i].push_back(make_pair(j,A[j]+B[j]-A[i]-B[i]));
    }
    for(int i=0;i<2*N;i++)
    {
        G[2*N].push_back(make_pair(i,A[i]+B[i]-2));
        G[i].push_back(make_pair(2*N+1,H+W-A[i]-B[i]));
    }
    cout<<(dijkstra(G,1L<<60,2*N)[2*N+1])<<endl;
}
0