結果
問題 | No.807 umg tours |
ユーザー | tottoripaper |
提出日時 | 2019-03-22 22:14:12 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 390 ms / 4,000 ms |
コード長 | 1,622 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 184,012 KB |
実行使用メモリ | 24,940 KB |
最終ジャッジ日時 | 2023-08-15 12:01:03 |
合計ジャッジ時間 | 7,669 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
7,292 KB |
testcase_01 | AC | 5 ms
7,304 KB |
testcase_02 | AC | 5 ms
7,300 KB |
testcase_03 | AC | 5 ms
7,360 KB |
testcase_04 | AC | 5 ms
7,280 KB |
testcase_05 | AC | 5 ms
7,564 KB |
testcase_06 | AC | 5 ms
7,316 KB |
testcase_07 | AC | 5 ms
7,308 KB |
testcase_08 | AC | 4 ms
7,256 KB |
testcase_09 | AC | 5 ms
7,404 KB |
testcase_10 | AC | 5 ms
7,256 KB |
testcase_11 | AC | 169 ms
18,700 KB |
testcase_12 | AC | 221 ms
15,508 KB |
testcase_13 | AC | 281 ms
18,404 KB |
testcase_14 | AC | 125 ms
12,000 KB |
testcase_15 | AC | 96 ms
10,816 KB |
testcase_16 | AC | 286 ms
19,328 KB |
testcase_17 | AC | 390 ms
23,944 KB |
testcase_18 | AC | 386 ms
23,760 KB |
testcase_19 | AC | 378 ms
19,988 KB |
testcase_20 | AC | 246 ms
12,724 KB |
testcase_21 | AC | 253 ms
12,900 KB |
testcase_22 | AC | 102 ms
9,688 KB |
testcase_23 | AC | 81 ms
9,128 KB |
testcase_24 | AC | 227 ms
21,304 KB |
testcase_25 | AC | 389 ms
24,940 KB |
ソースコード
#include <bits/stdc++.h> #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple<ll,ll>; using T = std::tuple<ll,ll,ll>; constexpr ll INF = std::numeric_limits<ll>::max() / 2; int N, M; std::vector<P> G[100100]; std::priority_queue<T, std::vector<T>, std::greater<T>> pq; ll dist[100100][2]; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N >> M; for(int i=0;i<M;++i){ int a, b, c; std::cin >> a >> b >> c; G[a].emplace_back(b, c); G[b].emplace_back(a, c); } std::fill(&dist[0][0], &dist[0][0] + 100100 * 2, INF); dist[1][0] = 0; dist[1][1] = 0; pq.emplace(0, 1, 0); until(pq.empty()){ int v, t; ll d; std::tie(d, v, t) = pq.top(); pq.pop(); if(d > dist[v][t]){ continue; } for(auto &e : G[v]){ int w, c; std::tie(w, c) = e; if(d + c < dist[w][t]){ dist[w][t] = d + c; pq.emplace(dist[w][t], w, t); } } if(t == 0){ for(auto &e : G[v]){ int w; std::tie(w, std::ignore) = e; if(d < dist[w][1]){ dist[w][1] = d; pq.emplace(dist[w][1], w, 1); } } } } for(int i=1;i<=N;++i){ ll mn = dist[i][0] + dist[i][1]; std::cout << mn << std::endl; } }