結果

問題 No.1601 With Animals into Institute
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-10 14:12:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 554 ms / 3,000 ms
コード長 793 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 209,984 KB
実行使用メモリ 45,588 KB
最終ジャッジ日時 2023-09-14 19:17:42
合計ジャッジ時間 11,384 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
27,912 KB
testcase_01 AC 10 ms
27,912 KB
testcase_02 AC 10 ms
28,200 KB
testcase_03 AC 17 ms
28,400 KB
testcase_04 AC 17 ms
28,400 KB
testcase_05 AC 17 ms
28,424 KB
testcase_06 AC 535 ms
45,480 KB
testcase_07 AC 540 ms
45,472 KB
testcase_08 AC 525 ms
45,388 KB
testcase_09 AC 533 ms
45,432 KB
testcase_10 AC 546 ms
45,308 KB
testcase_11 AC 545 ms
45,456 KB
testcase_12 AC 543 ms
45,344 KB
testcase_13 AC 550 ms
45,448 KB
testcase_14 AC 554 ms
45,368 KB
testcase_15 AC 542 ms
45,588 KB
testcase_16 AC 539 ms
45,424 KB
testcase_17 AC 543 ms
45,268 KB
testcase_18 AC 17 ms
28,736 KB
testcase_19 AC 17 ms
28,472 KB
testcase_20 AC 17 ms
28,640 KB
testcase_21 AC 17 ms
28,528 KB
testcase_22 AC 17 ms
28,500 KB
testcase_23 AC 17 ms
28,572 KB
testcase_24 AC 17 ms
28,468 KB
testcase_25 AC 17 ms
28,440 KB
testcase_26 AC 18 ms
28,544 KB
testcase_27 AC 10 ms
27,936 KB
testcase_28 AC 10 ms
27,896 KB
testcase_29 AC 10 ms
27,932 KB
testcase_30 AC 10 ms
27,932 KB
testcase_31 AC 10 ms
27,984 KB
testcase_32 AC 10 ms
27,916 KB
testcase_33 AC 10 ms
27,988 KB
testcase_34 AC 10 ms
28,044 KB
testcase_35 AC 10 ms
28,104 KB
testcase_36 AC 10 ms
28,208 KB
testcase_37 AC 10 ms
28,044 KB
testcase_38 AC 10 ms
27,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
using P=tuple<int,int,int>;
constexpr int INF=1e18;
struct edge{int to,cost,animal;};
bool chmin(int&a,int b){return a>b?a=b,true:false;}
vector<edge> G[1<<20];
int dist[1<<20][2];
signed main(){
    int N,M; cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b,c,d; cin>>a>>b>>c>>d;
        G[--a].push_back({--b,c,d});
        G[b].push_back({a,c,d});
    }
    fill(dist[0],dist[N],INF); dist[N-1][0]=0;
    priority_queue<P,vector<P>,greater<P>> Q; Q.push({0,N-1,0});
    while(!Q.empty()){
        auto[c,v,a]=Q.top(); Q.pop();
        if(dist[v][a]<c)continue;
        for(edge e:G[v])if(chmin(dist[e.to][a|e.animal],c+e.cost))Q.push({c+e.cost,e.to,a|e.animal});
    }
    for(int i=0;i<N-1;i++)cout<<dist[i][1]<<endl;
}
0