# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846043 | vjudge1 | Birmingham (COCI20_birmingham) | C++11 | 0 ms | 0 KiB |
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>
#define lg(a) (31 - __builtin_clz((a)))
#define endl ("\n")
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define st first
#define nd second
#define all(aa) aa.begin(), aa.end()
#define rall(aa) aa.rbegin(), aa.rend()
#define until(n, v) (int) (lower_bound(v.begin(), v.end(), n)-v.begin()) //# of elements < n
#define after(n, v) (int) (v.end()-upper_bound(v.begin(), v.end(), n)) //# of elements > n
#define sameas(n, v) (int) (upper_bound(v.begin(), v.end(), n) - lower_bound(v.begin(), v.end(), n)) //# of elements ==n
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;
/*
*/
void solve(){
int n, m, k, qq;
cin >> n >> m >> qq >> k;
queue<int> q;
for(int i=0; i<qq; i++){
int a; cin >> a;
a--;
q.push(a);
ans[a] = 0;
}
vector<vector<int>> g;
for(int i=0; i < m; i++){
int a, b; cin >> a >> b;
a--, b--;
g[a].pb(b);
g[b].pb(a);
}
vector<int> ans(n, -1);
while(!q.empty()){
int v = q.front();
q.pop();
for(auto u : g[v]){
if(ans[u]==-1){
ans[u] = ans[v] + 1;
q.push(u);
}
}
}
for(int i=0;i<n;i++){
int l = 0, r= n;
while(l<r){
int mid = (l+r)/2;
if(1ll*mid*(mid+1)*k/2 < ans[i])
l = mid+1;
else if(1ll*mid*(mid+1)*k/2 >= ans[i])
r = mid;
}
cout<<r<<' ';
}
}
int main(){
int test;
// cin >> test;
test =1;
while (test--){
solve();
}
}