Submission #998982

#TimeUsernameProblemLanguageResultExecution timeMemory
998982vjudge1Birmingham (COCI20_birmingham)C++17
70 / 70
102 ms10288 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5+5; int n, m, q, k; vector<int> G[N]; int dist[N]; void bfs() { queue<int> Q; for(int i = 1; i <= n; i ++) if(dist[i] == 0) Q.push(i); while(Q.size()) { int u = Q.front(); Q.pop(); for(int v : G[u]) if(dist[u] + 1 < dist[v]) { dist[v] = dist[u] + 1; Q.push(v); } } } int main() { cin >> n >> m >> q >> k; for(int i = 1; i <= n; i ++) dist[i] = N * 4; for(int i = 0; i < q; i ++) { int x; cin >> x; dist[x] = 0; } for(int i = 0; i < m; i ++) { int u, v; cin >> u >> v; G[u].push_back(v); G[v].push_back(u); } bfs(); for(int i = 1; i <= n; i ++) { int x = 0, add = 0, sm = 0; while(dist[i] > add) { x ++; sm += k; add += sm; } cout << x << ' '; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...