結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-10 23:53:28 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,036 bytes |
| コンパイル時間 | 17,628 ms |
| コンパイル使用メモリ | 287,720 KB |
| 最終ジャッジ日時 | 2025-01-12 19:53:55 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 4 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
//-------------------
struct Edge {
int to;
ll cost;
Edge(int to, ll ct): to(to), cost(ct) {}
};
constexpr int MX = 2e5+4;
vector<vector<Edge>> G(MX);
vector<ll> d1(MX, LINF);
int n,m;
void dijkstra(int s, vector<ll> &d) {
priority_queue<PII, vector<PII>, greater<PII> > que;
que.push({0, s});
d[s+n] = 0;
while (!que.empty()) {
PII p = que.top();
que.pop();
int v = p.second;
if (d[v] <= p.first) continue;
d[v] = p.first;
for (auto e: G[v]) {
if (d[e.to] > d[v] + e.cost) { // make code faster
que.push({d[v] + e.cost, e.to});
}
}
}
}
int main() {
cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
cin >> n >> m;
rep(i, m) {
int a,b; ll c; cin >> a >> b >> c;
G[a].emplace_back(b,c);
G[b].emplace_back(a,c);
G[a].emplace_back(b+n, 0);
G[b].emplace_back(a+n, 0);
G[a+n].emplace_back(b+n, c);
G[b+n].emplace_back(a+n, c);
// cout << G[a].back().to << " " << G[b].back().to << endl;
}
dijkstra(1, d1);
FOR(i,1,n) {
// cout << d1[i] << " ";
cout << d1[i] + d1[i+n] << endl;
}
return 0;
}