This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |