結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-03 20:48:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,287 bytes |
| コンパイル時間 | 4,144 ms |
| コンパイル使用メモリ | 255,224 KB |
| 最終ジャッジ日時 | 2025-02-11 22:45:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 22 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define LREP(i, n) for(LL i = 0; i < (LL)n; i++)
#define RREP(i, n) for(int i = (int)n-1; i >= 0; i--)
#define V(T) vector<T>
#define P pair<int, int>
#define LP pair<LL, LL>
#define T3 tuple<LL, LL, LL>
#define T4 tuple<LL, LL, LL, LL>
#define INF 1000000007
#define SIZE 500100
#define MOD 998244353
typedef long long LL;
LL N, M;
LL A[SIZE], B[SIZE], C[SIZE];
V(int) E[SIZE];
LL dist[SIZE];
int main() {
cin >> N >> M;
REP(i, M) {
cin >> A[i] >> B[i] >> C[i];
A[i]--; B[i]--;
E[A[i]].push_back(i);
E[B[i]].push_back(i);
}
REP(i, 2 * N) dist[i] = 1e18;
priority_queue<LP, V(LP), greater<LP>> que;
que.push(LP(0, 0)); // have a ticket
que.push(LP(0, N));
while (que.size()) {
LP p = que.top(); que.pop();
LL d = p.first, u = p.second;
if (dist[u] <= d) continue;
dist[u] = d;
for (auto i : E[u % N]) {
LL v = A[i], cost = C[i];
if (v == u) v = B[i];
if (u < N) {
que.push(LP(d + cost, v));
que.push(LP(d, v + N));
}
else {
que.push(LP(d + cost, v + N));
}
}
}
REP(i, N) {
cout << dist[i] + dist[i + N] << endl;
}
}