結果
問題 | No.807 umg tours |
ユーザー | kkey000 |
提出日時 | 2023-06-16 20:27:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,250 bytes |
コンパイル時間 | 1,970 ms |
コンパイル使用メモリ | 178,352 KB |
実行使用メモリ | 62,868 KB |
最終ジャッジ日時 | 2023-09-06 17:47:29 |
合計ジャッジ時間 | 18,396 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,384 KB |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 3 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 476 ms
15,908 KB |
testcase_12 | AC | 690 ms
22,328 KB |
testcase_13 | AC | 1,179 ms
36,280 KB |
testcase_14 | AC | 402 ms
19,056 KB |
testcase_15 | AC | 270 ms
18,712 KB |
testcase_16 | AC | 635 ms
24,848 KB |
testcase_17 | AC | 1,141 ms
26,972 KB |
testcase_18 | AC | 1,833 ms
62,868 KB |
testcase_19 | AC | 1,451 ms
38,024 KB |
testcase_20 | WA | - |
testcase_21 | AC | 304 ms
11,160 KB |
testcase_22 | WA | - |
testcase_23 | AC | 96 ms
6,004 KB |
testcase_24 | TLE | - |
testcase_25 | -- | - |
ソースコード
#include <bits/stdc++.h> #define INF 10e9 #define rep(i, a) for (int i = 0; i < (a); i++) using namespace std; typedef struct edge { int to; int cost; } edge; int main() { long long int n, m; cin >> n >> m; vector<edge> graph[n]; long long int u, v, c; long long int i, j; for (i = 0; i < m; i++) { cin >> u >> v >> c; edge e; e.to = v - 1; e.cost = c; graph[u - 1].push_back(e); e.to = u - 1; graph[v - 1].push_back(e); } long long int d[2][n]; for (i = 0; i < n; i++) { if (i == 0) { d[0][i] = 0; d[1][i] = 0; } else { d[0][i] = INF; d[1][i] = INF; } } priority_queue<pair<pair<long long int, long long int>, long long int>, vector<pair<pair<long long int, long long int>, long long int>>, greater<pair<pair<long long int, long long int>, long long int>>> q; q.push(make_pair(make_pair(0, 0), 0)); while (!q.empty()) { pair<pair<long long int, long long int>, long long int> p = q.top(); q.pop(); long long int v = p.first.first; for (i = 0; i < graph[v].size(); i++) { edge e = graph[v][i]; if (p.second == 0) { if (d[0][v] < p.first.second) continue; if (d[0][e.to] > d[0][v] + e.cost) { d[0][e.to] = d[0][v] + e.cost; q.push(make_pair(make_pair(e.to, d[0][e.to]), 0)); } if (d[1][e.to] > d[0][v]) { d[1][e.to] = d[0][v]; q.push(make_pair(make_pair(e.to, d[1][e.to]), 1)); } } else { if (d[1][v] < p.first.second) continue; if (d[1][e.to] > d[1][v] + e.cost) { d[1][e.to] = d[1][v] + e.cost; q.push(make_pair(make_pair(e.to, d[1][e.to]), 1)); } } } } for (i = 0; i < n; i++) { cout << (d[0][i] + d[1][i]) << endl; } }