結果
問題 |
No.807 umg tours
|
ユーザー |
![]() |
提出日時 | 2019-03-22 23:27:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,042 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 205,232 KB |
最終ジャッジ日時 | 2025-01-07 00:05:30 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 4 RE * 22 |
ソースコード
#include <bits/stdc++.h> #define INF 2147483647 #define INF_LL 9223372036854775807 #define MOD 1000000007 using namespace std; typedef long long int ll; typedef unsigned long long int ull; struct edge { ll to; ll cost; }; typedef pair<ll, ll> P; int main() { int N, M; cin >> N >> M; vector<vector<edge>> G(N*2, vector<edge>()); for (int i = 0; i < M; i++) { ll a, b, c; cin >> a >> b >> c; a--; b--; G[a].push_back({ b,c }); G[b].push_back({ a,c }); G[a].push_back({ b + N,0 }); G[b].push_back({ a + N,0 }); G[a + N].push_back({ b + N,0 }); G[b + N].push_back({ a + N,0 }); } vector<ll> d(N, INF); priority_queue<P, vector<P>, greater<P>> q; d[0] = 0; q.push(P{ 0,0 }); while (!q.empty()) { P p = q.top(); q.pop(); ll v = p.second; if (d[v] < p.first)continue; for (int i = 0; i < G[v].size(); i++) { edge e = G[v][i]; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; q.push(P{ d[e.to] , e.to }); } } } for (int i = 0; i < N; i++) { cout << d[i] + d[i+N] << endl; } }