結果
問題 | No.807 umg tours |
ユーザー | amesyu |
提出日時 | 2020-02-01 14:36:58 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,779 bytes |
コンパイル時間 | 2,559 ms |
コンパイル使用メモリ | 82,260 KB |
実行使用メモリ | 25,300 KB |
最終ジャッジ日時 | 2023-10-19 00:02:04 |
合計ジャッジ時間 | 7,744 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,268 KB |
testcase_01 | AC | 4 ms
5,268 KB |
testcase_02 | AC | 3 ms
5,292 KB |
testcase_03 | AC | 4 ms
5,284 KB |
testcase_04 | AC | 3 ms
5,264 KB |
testcase_05 | AC | 4 ms
5,268 KB |
testcase_06 | AC | 4 ms
5,296 KB |
testcase_07 | AC | 4 ms
5,284 KB |
testcase_08 | AC | 3 ms
5,244 KB |
testcase_09 | AC | 3 ms
5,248 KB |
testcase_10 | AC | 3 ms
5,256 KB |
testcase_11 | AC | 283 ms
18,632 KB |
testcase_12 | AC | 296 ms
16,536 KB |
testcase_13 | AC | 389 ms
19,528 KB |
testcase_14 | AC | 167 ms
10,972 KB |
testcase_15 | AC | 130 ms
9,448 KB |
testcase_16 | AC | 402 ms
20,460 KB |
testcase_17 | AC | 515 ms
25,252 KB |
testcase_18 | AC | 517 ms
25,300 KB |
testcase_19 | AC | 495 ms
21,328 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 305 ms
23,044 KB |
testcase_25 | AC | 515 ms
24,992 KB |
ソースコード
#include <iostream> #include <cstring> #include <string> #include <algorithm> #include <queue> using namespace std; #define INF 1000000000 typedef pair<long long int, long long int> P; typedef pair<long long int, P> T; typedef struct edge { long long int to; long long int cost; } edge; int main() { long long int n, m; long long int a, b, c; cin >> n >> m; vector<edge> graph[n]; long long int ans[2][100010]; for(long long int i=0;i<100010;i++) { ans[0][i] = INF; ans[1][i] = INF; } ans[0][0] = 0; ans[1][0] = 0; edge e; for(long long int i=0;i<m;i++) { cin >> a >> b >> c; e.to = b-1; e.cost = c; graph[a-1].push_back(e); e.to = a-1; e.cost = c; graph[b-1].push_back(e); } priority_queue < T, vector<T>, greater<T> > que; que.push(T(0, P(1, 0))); while(!que.empty()) { T q = que.top(); que.pop(); long long cost = q.first; long long int point = q.second.second; long long int ticket = q.second.first; if(cost > ans[ticket][point]) continue; for(int i=0;i<graph[point].size();i++) { long long int to1 = graph[point][i].to; long long int cost1 = graph[point][i].cost; if(ticket == 1) { if(cost < ans[0][to1]) { que.push(T(cost, P(0, to1))); ans[0][to1] = cost; } } if(cost1+cost < ans[ticket][to1]) { que.push(T(cost1+cost, P(ticket, to1))); ans[ticket][to1] = cost1+cost; } } } for(long long int i=0;i<n;i++) { cout << ans[0][i]+ans[1][i] << endl; } } //拡張ダイクストラXD