結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-03 00:16:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,253 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 186,940 KB |
| 実行使用メモリ | 63,568 KB |
| 最終ジャッジ日時 | 2024-06-29 23:58:37 |
| 合計ジャッジ時間 | 13,519 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 4 |
ソースコード
#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;
}
}