結果

問題 No.807 umg tours
ユーザー yurujirouyurujirou
提出日時 2023-04-03 20:48:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,287 bytes
コンパイル時間 4,305 ms
コンパイル使用メモリ 266,688 KB
実行使用メモリ 39,700 KB
最終ジャッジ日時 2023-10-25 06:52:15
合計ジャッジ時間 13,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 9 ms
22,160 KB
testcase_07 WA -
testcase_08 AC 7 ms
22,052 KB
testcase_09 AC 8 ms
22,056 KB
testcase_10 AC 7 ms
22,072 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
}
0