Submission #291720

#TimeUsernameProblemLanguageResultExecution timeMemory
291720penguinhackerBirmingham (COCI20_birmingham)C++17
70 / 70
111 ms10232 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=1e5; int n, m, starts, k; int d[mxN]; vector<int> adj[mxN]; queue<int> q; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> starts >> k; fill(d, d+n, -1); for (int i=0; i<starts; ++i) { int a; cin >> a, --a; d[a]=0; q.push(a); } for (int i=0; i<m; ++i) { int a, b; cin >> a >> b, --a, --b; adj[a].push_back(b); adj[b].push_back(a); } while(!q.empty()) { int u=q.front(); q.pop(); for (int v : adj[u]) if (d[v]==-1) { d[v]=d[u]+1; q.push(v); } } for (int i=0; i<n; ++i) { int ans=0; for (int j=1; d[i]>0; ++j) { ++ans; d[i]-=k*j; } cout << ans << " "; } 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...