Submission #845179

#TimeUsernameProblemLanguageResultExecution timeMemory
845179vjudge1Birmingham (COCI20_birmingham)C++17
70 / 70
72 ms10948 KiB
#include <bits/stdc++.h> using namespace std; const int N =1e5+37; #define int long long vector<int> adj[N]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, m, a, b; cin >> n >> m >> a >> b; vector<int> c(a), vis(n, -1); for(auto &i: c) cin >> i, i--, vis[i]=0; queue<int> q; for(int i=0; i<a; i++){ q.push(c[i]); } for(int i=0; i<m; i++){ int x, y; cin >> x >> y; x--; y--; adj[x].push_back(y); adj[y].push_back(x); } while(q.size()){ int v = q.front(); q.pop(); for(auto i: adj[v]){ if(vis[i]==-1){ vis[i]=vis[v]+1; q.push(i); } } } for(int l=0; l<n; l++){ int k=(vis[l]+b-1)/b; int s=-1; for(int j=20; j>=0; j--){ int tmp = s+(1<<j); if((tmp*(tmp+1))/2>=k) continue; s=tmp; } cout<<s+1<<" "; } }
#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...