結果

問題 No.807 umg tours
ユーザー 👑 deuteridayodeuteridayo
提出日時 2021-02-03 00:16:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,253 bytes
コンパイル時間 2,694 ms
コンパイル使用メモリ 184,532 KB
実行使用メモリ 64,272 KB
最終ジャッジ日時 2023-09-12 11:30:10
合計ジャッジ時間 17,156 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1,190 ms
47,536 KB
testcase_12 AC 709 ms
38,484 KB
testcase_13 AC 1,169 ms
53,632 KB
testcase_14 AC 362 ms
27,984 KB
testcase_15 AC 257 ms
20,536 KB
testcase_16 AC 1,168 ms
47,292 KB
testcase_17 AC 1,389 ms
62,796 KB
testcase_18 AC 1,430 ms
61,960 KB
testcase_19 AC 1,408 ms
61,332 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 537 ms
58,828 KB
testcase_25 AC 1,468 ms
64,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
using graph = vector<vector<int>>;
#define endl '\n'
lint const mod = 1e9+7;
//long const mod = 998244353;


int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m],c[m];
    vector<unordered_map<int,lint>>dist(n);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }
    vector<vector<lint>> ans(n,vector<lint>(2,1<<30));
    ans[0][1] = 0;
    priority_queue<vector<lint> , vector<vector<lint>>, greater<vector<lint>>>que; // cost, v, state

    que.push({0,0,0});
    while(!que.empty()){
        lint cost = que.top()[0];
        lint v = que.top()[1];
        lint state = que.top()[2];
        que.pop();
        if(cost >= ans[v][state])continue;
        ans[v][state] = cost;
        for(auto e: dist[v]){
            lint nv = e.first;
            lint ncost = e.second;
            que.push({cost + ncost, nv, state});
            if(state == 0){
                que.push({cost, nv, 1});
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i][0] + ans[i][1] << endl;
    }

}

0