# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36514 | 2017-12-10T06:23:22 Z | WhipppedCream | Price List (POI13_cen) | C++14 | 99 ms | 19328 KB |
#include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vvi vector< vi > #define vii vector< ii > #define mp make_pair #define pb push_back const int maxn = 1e5+5; int n, m, k, a, b; vector<int> adj[maxn]; set<int> has[maxn]; vector<int> active[maxn]; bool vis[maxn]; int dist[maxn]; int dist2[maxn]; int p[maxn]; void bfs(int *dist) { for(int i = 1; i<= n; i++) dist[i] = 1e9; dist[k] = 0; queue<int> Q; Q.push(k); while(!Q.empty()) { int u = Q.front(); Q.pop(); for(auto v : adj[u]) { if(dist[v]> dist[u]+1) { dist[v] = dist[u]+1; Q.push(v); } } } } void bfs2(int *dist) { for(int i = 1; i<= n; i++) dist[i] = 1e9; queue<int> Q; Q.push(k); dist[k] = 0; vis[k] = 1; for(int i = 1; i<= n; i++) active[i] = adj[i]; while(!Q.empty()) { int u = Q.front(); Q.pop(); for(auto v : adj[u]) { vector<int> temp; for(auto w : active[v]) { if(vis[w]) continue; if(has[u].find(w) != has[u].end()) continue; vis[w] = 1; dist[w] = dist[u]+1; temp.pb(w); } active[v] = temp; } } } int main() { //#ifndef atom //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); //#endif scanf("%d %d %d %d %d", &n, &m, &k, &a, &b); for(int i = 1; i<= m; i++) { int a, b; scanf("%d %d", &a, &b); adj[a].pb(b); adj[b].pb(a); } bfs(dist); bfs2(dist2); //for(int i = 1; i<= n; i++) printf("%d\n", dist2[i]); for(int i = 1; i<= n; i++) { int x = (dist[i]/2)*min(2*a, b)+(dist[i]%2)*a; int y = 1e9; if(dist2[i] != 1e9) y = dist2[i]*b; printf("%d\n", min(x, y)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12664 KB | Output is correct |
2 | Correct | 0 ms | 12664 KB | Output is correct |
3 | Incorrect | 6 ms | 12664 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 12664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 12664 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 13460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 49 ms | 15588 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 79 ms | 17512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 83 ms | 18480 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 93 ms | 19328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 99 ms | 18780 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 89 ms | 18868 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |