結果
問題 | No.807 umg tours |
ユーザー | gazelle |
提出日時 | 2019-03-22 21:34:17 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 462 ms / 4,000 ms |
コード長 | 1,655 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 131,072 KB |
実行使用メモリ | 28,036 KB |
最終ジャッジ日時 | 2023-08-15 11:50:37 |
合計ジャッジ時間 | 7,715 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 186 ms
16,548 KB |
testcase_12 | AC | 265 ms
16,640 KB |
testcase_13 | AC | 337 ms
19,832 KB |
testcase_14 | AC | 141 ms
11,004 KB |
testcase_15 | AC | 98 ms
9,148 KB |
testcase_16 | AC | 333 ms
20,724 KB |
testcase_17 | AC | 462 ms
27,396 KB |
testcase_18 | AC | 451 ms
27,500 KB |
testcase_19 | AC | 443 ms
23,484 KB |
testcase_20 | AC | 273 ms
16,172 KB |
testcase_21 | AC | 283 ms
16,540 KB |
testcase_22 | AC | 106 ms
9,120 KB |
testcase_23 | AC | 82 ms
7,708 KB |
testcase_24 | AC | 231 ms
25,092 KB |
testcase_25 | AC | 458 ms
28,036 KB |
ソースコード
#include<iostream> #include<iomanip> #include<vector> #include<algorithm> #include<set> #include<map> #include<unordered_map> #include<stack> #include<queue> #include<math.h> #include<functional> #include<bitset> using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(int)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;} #define ALL(v) v.begin(),v.end() #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end()); #define pb push_back int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<vector<pll>> g(n); REP(i, m) { ll a, b, c; cin >> a >> b >> c; a--; b--; g[a].pb({b, c}); g[b].pb({a, c}); } vector<vector<ll>> dir(n, vector<ll>(2, INF * INF)); dir[0][0] = 0; priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> q; q.push({0, {0, 0}}); while(!q.empty()) { ll c = q.top().first; ll p = q.top().second.first, d = q.top().second.second; q.pop(); if(dir[p][d] != c) continue; REP(i, g[p].size()) { ll np = g[p][i].first, cost = g[p][i].second; if(dir[np][d] > c + cost) { dir[np][d] = c + cost; q.push({dir[np][d], {np, d}}); } if(d == 0 && dir[np][1] > c) { dir[np][1] = c; q.push({dir[np][1], {np, 1}}); } } } REP(i, n) { if(i == 0) { cout << 0 << endl; } else { cout << dir[i][0] + dir[i][1] << endl; } } return 0; } /* --------------------------------------- */