結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
Tlapesium
|
| 提出日時 | 2019-03-22 23:27:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,048 bytes |
| コンパイル時間 | 2,224 ms |
| コンパイル使用メモリ | 204,932 KB |
| 最終ジャッジ日時 | 2025-01-07 00:05:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 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>());
vector<ll> d(N * 2, INF);
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 });
}
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;
}
}
Tlapesium