Submission #709951

#TimeUsernameProblemLanguageResultExecution timeMemory
709951pccBirmingham (COCI20_birmingham)C++14
70 / 70
229 ms10240 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxn = 1e5+10; vector<int> paths[mxn]; int dist[mxn]; int main(){ ll n,m,qq,k; fill(dist,dist+mxn,-1); cin>>n>>m>>qq>>k; queue<int> q; for(int i = 0;i<qq;i++){ int x; cin>>x; q.push(x); dist[x] = 0; } for(int i = 0;i<m;i++){ int a,b; cin>>a>>b; paths[a].push_back(b); paths[b].push_back(a); } while(!q.empty()){ auto now = q.front(); q.pop(); for(auto nxt:paths[now]){ if(dist[nxt] != -1)continue; dist[nxt] = dist[now]+1; q.push(nxt); } } for(int i = 1;i<=n;i++){ ll l = 0,r = n; while(l != r){ ll mid = (l+r)>>1; if(mid*(mid+1)/2*k>=dist[i])r = mid; else l = mid+1; } cout<<l<<' '; } } /* 6 8 1 1 6 1 3 1 5 1 6 2 5 2 6 3 4 3 5 5 6 */
#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...