結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
kyort0n
|
| 提出日時 | 2019-03-25 02:43:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,357 bytes |
| コンパイル時間 | 1,499 ms |
| コンパイル使用メモリ | 174,076 KB |
| 実行使用メモリ | 26,868 KB |
| 最終ジャッジ日時 | 2024-10-05 07:55:25 |
| 合計ジャッジ時間 | 8,648 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 5 |
ソースコード
#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, 100001});
while(!que.empty()) {
l_l now = que.top();
que.pop();
int pos = now.second % (100000);
int index = now.second / 100000;
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 * 100000});
if(index == 0) {
que.push({cost, to.first + 100000});
}
}
}
for(int i = 1; i <= N; i++) {
cout << dist[i][0] + dist[i][1] << endl;
}
return 0;
}
kyort0n