結果
問題 |
No.1301 Strange Graph Shortest Path
|
ユーザー |
![]() |
提出日時 | 2020-11-27 23:33:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,914 bytes |
コンパイル時間 | 1,773 ms |
コンパイル使用メモリ | 178,472 KB |
実行使用メモリ | 11,988 KB |
最終ジャッジ日時 | 2024-09-13 01:11:36 |
合計ジャッジ時間 | 6,486 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 WA * 5 |
ソースコード
//#pragma GCC optimize ("O2") //#pragma GCC target ("avx2") #include<bits/stdc++.h> //#include<atcoder/all> //using namespace atcoder; using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define Would #define you #define please vector<pair<int, int>> E[100001]; int C[100001], D[100001]; pair<int, int> mae[100001]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; rep(i, M) { int u, v, c, d; cin >> u >> v >> c >> d; E[u].pb({ v, i }); E[v].pb({ u, i }); C[i] = c; D[i] = d; } #define PT pair<ll, int> ll Di[100001]; rep1(i, N) Di[i] = 1e18; priority_queue<PT, vector<PT>, greater<PT>> que; Di[1] = 0; que.push(mp(0, 1)); while (que.size()) { PT p = que.top(); que.pop(); int i = p.second; if (Di[i] != p.first) continue; for (PT p2 : E[i]) { int j = p2.first; int cc = C[p2.second]; int dd = C[p2.second]; ll d = Di[i] + cc; if (Di[j] > d) { Di[j] = d; mae[j] = { i, p2.second }; que.push(mp(d, j)); } } } int tmp = N; while (mae[tmp].first) { C[mae[tmp].second] = D[mae[tmp].second]; tmp = mae[tmp].first; } ll are = Di[N]; rep1(i, N) Di[i] = 1e18; Di[1] = 0; que.push(mp(0, 1)); while (que.size()) { PT p = que.top(); que.pop(); int i = p.second; if (Di[i] != p.first) continue; for (PT p2 : E[i]) { int j = p2.first; int cc = C[p2.second]; int dd = C[p2.second]; ll d = Di[i] + cc; if (Di[j] > d) { Di[j] = d; mae[j] = { i, p2.second }; que.push(mp(d, j)); } } } co(are + Di[N]); Would you please return 0; }