結果
問題 | No.807 umg tours |
ユーザー | kyort0n |
提出日時 | 2019-03-25 02:48:00 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 587 ms / 4,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 1,699 ms |
コンパイル使用メモリ | 171,552 KB |
実行使用メモリ | 26,532 KB |
最終ジャッジ日時 | 2023-08-15 12:16:32 |
合計ジャッジ時間 | 9,176 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,812 KB |
testcase_01 | AC | 4 ms
5,788 KB |
testcase_02 | AC | 5 ms
5,980 KB |
testcase_03 | AC | 4 ms
5,824 KB |
testcase_04 | AC | 4 ms
5,728 KB |
testcase_05 | AC | 4 ms
5,724 KB |
testcase_06 | AC | 4 ms
5,844 KB |
testcase_07 | AC | 4 ms
5,972 KB |
testcase_08 | AC | 3 ms
5,748 KB |
testcase_09 | AC | 4 ms
5,796 KB |
testcase_10 | AC | 4 ms
5,828 KB |
testcase_11 | AC | 366 ms
22,864 KB |
testcase_12 | AC | 316 ms
16,264 KB |
testcase_13 | AC | 453 ms
24,360 KB |
testcase_14 | AC | 180 ms
15,376 KB |
testcase_15 | AC | 142 ms
10,824 KB |
testcase_16 | AC | 472 ms
20,092 KB |
testcase_17 | AC | 583 ms
25,720 KB |
testcase_18 | AC | 587 ms
25,876 KB |
testcase_19 | AC | 573 ms
25,592 KB |
testcase_20 | AC | 308 ms
12,752 KB |
testcase_21 | AC | 317 ms
13,028 KB |
testcase_22 | AC | 130 ms
9,040 KB |
testcase_23 | AC | 96 ms
8,056 KB |
testcase_24 | AC | 307 ms
21,584 KB |
testcase_25 | AC | 585 ms
26,532 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e18) #define PI (acos(-1)) //const ll mod = 1000000007; ll dist[100500][2]; vector<l_l> pathes[100500]; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; for(int i = 1; i <= M; i++) { ll a, b, c; cin >> a >> b >> c; pathes[a].push_back({b, c}); pathes[b].push_back({a, c}); } priority_queue<l_l, vector<l_l>, greater<l_l> > que; for(int i = 1; i <= N; i++) { for(int j = 0; j <= 1; j++) dist[i][j] = INF; } que.push({0, 1}); que.push({0, 200001}); while(!que.empty()) { l_l now = que.top(); que.pop(); int pos = now.second % (200000); int index = now.second / 200000; ll cost = now.first; if(dist[pos][index] <= cost) continue; dist[pos][index] = cost; for(int i = 0; i < pathes[pos].size(); i++) { l_l to = pathes[pos][i]; que.push({cost + to.second, to.first + index * 200000}); if(index == 0) { que.push({cost, to.first + 200000}); } } } for(int i = 1; i <= N; i++) { cout << dist[i][0] + dist[i][1] << endl; } return 0; }