結果

問題 No.807 umg tours
ユーザー 👑 deuteridayodeuteridayo
提出日時 2021-02-03 00:21:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,275 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 184,312 KB
実行使用メモリ 63,392 KB
最終ジャッジ日時 2023-09-12 11:30:29
合計ジャッジ時間 16,025 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1,190 ms
46,660 KB
testcase_12 AC 676 ms
38,216 KB
testcase_13 AC 1,116 ms
53,472 KB
testcase_14 AC 379 ms
27,424 KB
testcase_15 AC 276 ms
19,736 KB
testcase_16 AC 1,206 ms
47,424 KB
testcase_17 AC 1,470 ms
62,392 KB
testcase_18 AC 1,507 ms
62,128 KB
testcase_19 AC 1,371 ms
61,496 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 571 ms
59,552 KB
testcase_25 AC 1,466 ms
63,392 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
    dist[0][0] = 0;
    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