結果

問題 No.807 umg tours
ユーザー ngtkanangtkana
提出日時 2020-03-30 22:21:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,119 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 209,648 KB
実行使用メモリ 42,356 KB
最終ジャッジ日時 2023-08-15 12:45:29
合計ジャッジ時間 11,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 173 ms
32,104 KB
testcase_12 AC 152 ms
24,264 KB
testcase_13 AC 218 ms
33,020 KB
testcase_14 AC 86 ms
15,856 KB
testcase_15 AC 59 ms
13,492 KB
testcase_16 AC 230 ms
34,956 KB
testcase_17 AC 310 ms
40,764 KB
testcase_18 AC 300 ms
42,356 KB
testcase_19 AC 280 ms
39,008 KB
testcase_20 AC 136 ms
22,628 KB
testcase_21 AC 137 ms
23,272 KB
testcase_22 AC 50 ms
11,976 KB
testcase_23 AC 37 ms
10,092 KB
testcase_24 TLE -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::vector<std::vector<std::pair<lint,lint>>>g(2*n);
    while(m--){
        lint a,b,c;std::cin>>a>>b>>c;a--,b--;
        g.at(a).emplace_back(b,c);
        g.at(b).emplace_back(a,c);
        g.at(a).emplace_back(n+b,0);
        g.at(b).emplace_back(n+a,0);
        g.at(n+a).emplace_back(n+b,c);
        g.at(n+b).emplace_back(n+a,c);
    }
    lint inf=std::numeric_limits<lint>::max();
    std::vector<lint>dist(2*n,inf);
    dist.at(0)=0;
    std::priority_queue<std::pair<lint,lint>>que;
    que.emplace(0,0);
    while(!que.empty()){
        lint x=que.top().second;que.pop();
        for(auto&&[y,w]:g.at(x)){
            lint d=dist.at(x)+w;
            if(dist.at(y)<=d)continue;
            que.emplace(-d,y);
            dist.at(y)=d;
        }
    }
    std::cout<<0<<'\n';
    for(lint i=1;i<n;i++){
        std::cout<<dist.at(i)+dist.at(n+i)<<'\n';
    }
}
0