結果

問題 No.1344 Typical Shortest Path Sum
ユーザー shiomusubi496shiomusubi496
提出日時 2021-01-16 13:16:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 849 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 176,324 KB
実行使用メモリ 35,828 KB
最終ジャッジ日時 2024-05-05 15:13:07
合計ジャッジ時間 6,750 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
33,408 KB
testcase_01 AC 10 ms
28,160 KB
testcase_02 AC 11 ms
28,032 KB
testcase_03 AC 10 ms
28,032 KB
testcase_04 AC 11 ms
28,160 KB
testcase_05 AC 10 ms
27,904 KB
testcase_06 AC 11 ms
28,160 KB
testcase_07 AC 11 ms
28,160 KB
testcase_08 AC 11 ms
28,032 KB
testcase_09 AC 11 ms
28,032 KB
testcase_10 AC 11 ms
28,160 KB
testcase_11 AC 11 ms
28,032 KB
testcase_12 AC 10 ms
28,160 KB
testcase_13 AC 11 ms
27,904 KB
testcase_14 AC 10 ms
28,032 KB
testcase_15 AC 11 ms
28,160 KB
testcase_16 AC 11 ms
28,032 KB
testcase_17 AC 11 ms
27,904 KB
testcase_18 AC 10 ms
28,032 KB
testcase_19 AC 10 ms
27,904 KB
testcase_20 AC 11 ms
28,032 KB
testcase_21 AC 11 ms
28,032 KB
testcase_22 AC 11 ms
28,160 KB
testcase_23 AC 11 ms
28,032 KB
testcase_24 AC 11 ms
27,904 KB
testcase_25 AC 11 ms
28,032 KB
testcase_26 AC 12 ms
28,032 KB
testcase_27 AC 11 ms
28,032 KB
testcase_28 AC 11 ms
28,032 KB
testcase_29 AC 11 ms
28,032 KB
testcase_30 AC 12 ms
28,032 KB
testcase_31 AC 10 ms
28,032 KB
testcase_32 AC 10 ms
28,032 KB
testcase_33 AC 10 ms
27,904 KB
testcase_34 AC 11 ms
28,032 KB
testcase_35 AC 11 ms
28,160 KB
testcase_36 AC 11 ms
28,160 KB
testcase_37 AC 12 ms
28,032 KB
testcase_38 AC 11 ms
28,160 KB
testcase_39 AC 11 ms
28,032 KB
testcase_40 AC 11 ms
28,032 KB
testcase_41 AC 11 ms
28,032 KB
testcase_42 AC 11 ms
28,032 KB
testcase_43 AC 12 ms
28,160 KB
testcase_44 AC 11 ms
28,032 KB
testcase_45 AC 11 ms
28,032 KB
testcase_46 AC 12 ms
28,032 KB
testcase_47 AC 11 ms
28,032 KB
testcase_48 AC 11 ms
28,160 KB
testcase_49 AC 11 ms
28,032 KB
testcase_50 AC 11 ms
28,032 KB
testcase_51 AC 12 ms
28,032 KB
testcase_52 AC 11 ms
28,160 KB
testcase_53 AC 12 ms
28,032 KB
testcase_54 AC 12 ms
27,904 KB
testcase_55 AC 11 ms
28,160 KB
testcase_56 AC 11 ms
28,032 KB
testcase_57 AC 11 ms
28,160 KB
testcase_58 AC 12 ms
28,032 KB
testcase_59 AC 12 ms
28,032 KB
testcase_60 AC 15 ms
28,160 KB
testcase_61 AC 11 ms
28,032 KB
testcase_62 TLE -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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