結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
Kiona1018
|
| 提出日時 | 2019-09-14 22:01:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,389 bytes |
| コンパイル時間 | 1,964 ms |
| コンパイル使用メモリ | 181,188 KB |
| 実行使用メモリ | 79,872 KB |
| 最終ジャッジ日時 | 2024-07-06 14:49:58 |
| 合計ジャッジ時間 | 17,566 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 26 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
const int MAX_N = 100000;
const ll INF = 1e18;
struct edge{int to, weight;};
vector<edge> from[MAX_N];
int main()
{
int n, m;
cin >> n >> m;
rep(i, 0, m)
{
int a, b, c;
cin >> a >> b >> c;
--a, --b;
edge e{b, c};
from[a].push_back(edge{b, c});
from[b].push_back(edge{a, c});
}
vector<ll> dis(2*n, INF);
priority_queue<pll, vector<pll>, greater<pll>> que;
que.push(make_pair(0, 0));
while (que.size() > 0)
{
ll node, distance;
tie(node, distance) = que.top();
que.pop();
if (dis[node] < distance) continue;
dis[node] = distance;
if (n <= node)
for (edge e: from[node % n])
que.push(make_pair(n + e.to, (ll)distance + e.weight));
else
{
for (edge e: from[node])
{
que.push(make_pair(e.to, (ll) distance + e.weight));
que.push(make_pair(e.to + n, (ll) distance));
}
}
}
rep(i, 0, n)
cout << (ll) dis[i] + dis[n + i] << endl;
// cout << dis[i] << endl;
return 0;
}
Kiona1018