Submission #3609416
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}; vvt<pair<int, int>> edge(101000); void dijkstra(int s, vt<i64> &cost, vt<i64> &dist) { priority_queue<pair<int, i64>, vt<pair<int, i64>>, greater<pair<int, i64>>> que; que.push({s, 0}); while(!que.empty()) { int v = que.top().first; i64 d = que.top().second; que.pop(); if(dist[v] < d) continue; dist[v] = d; for(auto &nxt : edge[v]) { que.push({nxt.first, dist[v] + cost[nxt.second]}); } } } 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--; edge[u].push_back({v, i}); edge[v].push_back({u, i}); } vt<i64> dist1(n, 1e18), dist2(n, 1e18); dijkstra(s, a, dist1); dijkstra(t, b, dist2); 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); } reverse(all(ans)); for(auto &it : ans) cout << it << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Saving Snuuk |
User | playroller |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1611 Byte |
Status | TLE |
Exec Time | 2114 ms |
Memory | 1057740 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 207 ms | 11380 KB |
11_0.txt | AC | 1035 ms | 22636 KB |
11_1.txt | AC | 1215 ms | 35960 KB |
11_2.txt | AC | 998 ms | 32704 KB |
11_3.txt | AC | 584 ms | 12688 KB |
11_4.txt | AC | 834 ms | 21972 KB |
1n1m1.txt | TLE | 2114 ms | 1057740 KB |
1oo_0.txt | AC | 957 ms | 23236 KB |
1oo_1.txt | AC | 1099 ms | 23628 KB |
1oo_2.txt | TLE | 2104 ms | 56008 KB |
1oo_3.txt | AC | 801 ms | 16476 KB |
1oo_4.txt | AC | 857 ms | 22180 KB |
dangou_0.txt | TLE | 2114 ms | 1056976 KB |
dangou_1.txt | AC | 824 ms | 21864 KB |
dangou_2.txt | AC | 610 ms | 15476 KB |
dangou_3.txt | TLE | 2105 ms | 267872 KB |
dangou_4.txt | AC | 523 ms | 12728 KB |
edge.txt | AC | 245 ms | 11380 KB |
high_0.txt | AC | 248 ms | 13520 KB |
high_1.txt | AC | 371 ms | 19004 KB |
high_2.txt | AC | 644 ms | 12920 KB |
high_3.txt | AC | 15 ms | 3472 KB |
high_4.txt | AC | 274 ms | 9312 KB |
low_0.txt | AC | 868 ms | 31576 KB |
low_1.txt | AC | 1012 ms | 32844 KB |
low_2.txt | AC | 655 ms | 14064 KB |
low_3.txt | AC | 566 ms | 11648 KB |
low_4.txt | AC | 594 ms | 15724 KB |
oo1_0.txt | AC | 963 ms | 25080 KB |
oo1_1.txt | AC | 945 ms | 23644 KB |
oo1_2.txt | AC | 1039 ms | 25064 KB |
oo1_3.txt | AC | 1142 ms | 34868 KB |
oo1_4.txt | AC | 975 ms | 23024 KB |
path_0.txt | AC | 204 ms | 10104 KB |
path_1.txt | AC | 200 ms | 10104 KB |
path_2.txt | AC | 98 ms | 6392 KB |
path_3.txt | AC | 119 ms | 7292 KB |
path_4.txt | AC | 67 ms | 5244 KB |
path_5.txt | AC | 178 ms | 9204 KB |
rnd_0.txt | AC | 678 ms | 21728 KB |
rnd_1.txt | AC | 744 ms | 14356 KB |
rnd_2.txt | AC | 117 ms | 6844 KB |
rnd_3.txt | AC | 718 ms | 16276 KB |
rnd_4.txt | AC | 807 ms | 23264 KB |
sampleRnd.txt | AC | 3 ms | 2688 KB |
sampleT.txt | AC | 3 ms | 2688 KB |
slast_0.txt | AC | 835 ms | 21720 KB |
slast_1.txt | AC | 434 ms | 16108 KB |
slast_2.txt | AC | 674 ms | 15628 KB |
slast_3.txt | AC | 774 ms | 23944 KB |
slast_4.txt | AC | 726 ms | 16268 KB |
tlast_0.txt | AC | 500 ms | 21960 KB |
tlast_1.txt | AC | 862 ms | 22340 KB |
tlast_2.txt | AC | 682 ms | 16720 KB |
tlast_3.txt | AC | 521 ms | 12728 KB |
tlast_4.txt | AC | 565 ms | 12684 KB |