Submission #3609410
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define rep(i, j, n) for(int i=j;i<n;++i) #define all(i) i.begin(),i.end() #define rall(i) i.rbegin(),i.rend() #define INF 1e9 const int mod = 1e9 + 7; typedef long long i64; typedef pair<int, int> pi; template <class T> using vt = vector<T>; template <class T> using vvt = vector<vector<T>>; i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));} i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);} int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; struct edge { int to, idx; }; vvt<edge> e(101000); vt<i64> dijkstra(int s, vt<i64> &cost) { vt<i64> dist(101000, 1e18); dist[s] = 0; priority_queue<pair<int, i64>, vt<pair<int, i64>>, greater<pair<int, i64>>> que; que.push({s, 0}); while(!que.empty()) { auto p = que.top(); que.pop(); int v = p.first; i64 d = p.second; if(dist[v] < d) continue; for(auto &nxt : e[v]) { if(dist[nxt.to] <= dist[v] + cost[nxt.idx]) continue; dist[nxt.to] = dist[v] + cost[nxt.idx]; que.push({nxt.to, dist[nxt.to]}); } } return dist; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m, s, t; cin >> n >> m >> s >> t; s--; t--; vt<i64> a(m), b(m); rep(i, 0, m) { int u, v; cin >> u >> v >> a[i] >> b[i]; u--; v--; e[u].push_back({v, i}); e[v].push_back({u, i}); } auto dist1 = dijkstra(s, a); auto dist2 = dijkstra(t, b); vt<i64> ans; i64 res = 0; for(int i = n - 1; i >= 0; --i) { res = max(res, (i64)1e15 - dist1[i] - dist2[i]); ans.push_back(res); } for(int i = n - 1; i >= 0; --i) cout << ans[i] << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Saving Snuuk |
User | playroller |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1732 Byte |
Status | AC |
Exec Time | 557 ms |
Memory | 16832 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sampleRnd.txt, sampleT.txt |
All | 00yorimichi.txt, 11_0.txt, 11_1.txt, 11_2.txt, 11_3.txt, 11_4.txt, 1n1m1.txt, 1oo_0.txt, 1oo_1.txt, 1oo_2.txt, 1oo_3.txt, 1oo_4.txt, dangou_0.txt, dangou_1.txt, dangou_2.txt, dangou_3.txt, dangou_4.txt, edge.txt, high_0.txt, high_1.txt, high_2.txt, high_3.txt, high_4.txt, low_0.txt, low_1.txt, low_2.txt, low_3.txt, low_4.txt, oo1_0.txt, oo1_1.txt, oo1_2.txt, oo1_3.txt, oo1_4.txt, path_0.txt, path_1.txt, path_2.txt, path_3.txt, path_4.txt, path_5.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, sampleRnd.txt, sampleT.txt, slast_0.txt, slast_1.txt, slast_2.txt, slast_3.txt, slast_4.txt, tlast_0.txt, tlast_1.txt, tlast_2.txt, tlast_3.txt, tlast_4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00yorimichi.txt | AC | 201 ms | 11380 KB |
11_0.txt | AC | 357 ms | 13796 KB |
11_1.txt | AC | 67 ms | 9356 KB |
11_2.txt | AC | 141 ms | 11892 KB |
11_3.txt | AC | 341 ms | 12744 KB |
11_4.txt | AC | 380 ms | 14656 KB |
1n1m1.txt | AC | 143 ms | 9808 KB |
1oo_0.txt | AC | 315 ms | 13664 KB |
1oo_1.txt | AC | 373 ms | 15608 KB |
1oo_2.txt | AC | 36 ms | 7808 KB |
1oo_3.txt | AC | 333 ms | 12748 KB |
1oo_4.txt | AC | 316 ms | 15316 KB |
dangou_0.txt | AC | 38 ms | 7808 KB |
dangou_1.txt | AC | 281 ms | 14928 KB |
dangou_2.txt | AC | 417 ms | 12176 KB |
dangou_3.txt | AC | 43 ms | 7408 KB |
dangou_4.txt | AC | 421 ms | 12840 KB |
edge.txt | AC | 223 ms | 11380 KB |
high_0.txt | AC | 82 ms | 8796 KB |
high_1.txt | AC | 92 ms | 9744 KB |
high_2.txt | AC | 452 ms | 12576 KB |
high_3.txt | AC | 8 ms | 4736 KB |
high_4.txt | AC | 224 ms | 9864 KB |
low_0.txt | AC | 43 ms | 8648 KB |
low_1.txt | AC | 51 ms | 8524 KB |
low_2.txt | AC | 387 ms | 12052 KB |
low_3.txt | AC | 357 ms | 11400 KB |
low_4.txt | AC | 200 ms | 11372 KB |
oo1_0.txt | AC | 420 ms | 16252 KB |
oo1_1.txt | AC | 270 ms | 13316 KB |
oo1_2.txt | AC | 200 ms | 12940 KB |
oo1_3.txt | AC | 82 ms | 9660 KB |
oo1_4.txt | AC | 172 ms | 12136 KB |
path_0.txt | AC | 189 ms | 10360 KB |
path_1.txt | AC | 186 ms | 10360 KB |
path_2.txt | AC | 92 ms | 7288 KB |
path_3.txt | AC | 114 ms | 8060 KB |
path_4.txt | AC | 64 ms | 6396 KB |
path_5.txt | AC | 160 ms | 9588 KB |
rnd_0.txt | AC | 413 ms | 15624 KB |
rnd_1.txt | AC | 557 ms | 14124 KB |
rnd_2.txt | AC | 17 ms | 5248 KB |
rnd_3.txt | AC | 486 ms | 12972 KB |
rnd_4.txt | AC | 275 ms | 15296 KB |
sampleRnd.txt | AC | 3 ms | 4224 KB |
sampleT.txt | AC | 3 ms | 4224 KB |
slast_0.txt | AC | 477 ms | 16740 KB |
slast_1.txt | AC | 53 ms | 7960 KB |
slast_2.txt | AC | 478 ms | 15460 KB |
slast_3.txt | AC | 325 ms | 15440 KB |
slast_4.txt | AC | 462 ms | 16484 KB |
tlast_0.txt | AC | 88 ms | 9724 KB |
tlast_1.txt | AC | 436 ms | 16708 KB |
tlast_2.txt | AC | 477 ms | 16832 KB |
tlast_3.txt | AC | 394 ms | 12812 KB |
tlast_4.txt | AC | 413 ms | 12704 KB |