Submission #570429

#TimeUsernameProblemLanguageResultExecution timeMemory
570429NekoRollyBirmingham (COCI20_birmingham)C++17
70 / 70
137 ms10112 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5+4; int n,m,q,k; vector<int> adj[N]; queue<int> d; int dis[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> q >> k; for (int i=1; i<=n; i++) dis[i] = -1; for (int a; q; q--){ cin >> a; dis[a] = 0; d.push(a); } for (int a,b; m; m--){ cin >> a >> b; adj[a].push_back(b), adj[b].push_back(a); } for (int u; d.size(); d.pop()){ u = d.front(); for (int v : adj[u]) if (dis[v] == -1){ dis[v] = dis[u]+1; d.push(v); } } for (int i=1,l,r; i<=n; i++){ l = 0, r = n; while (l < r){ int m = (l+r)>>1; if (1ll*m*(m+1)/2*k < dis[i]) l = m+1; else r = m; } cout << l << " "; } cout << "\n"; 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...