#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define pb push_back
#define lim 300000
#define till 40001
// # of primes till 1e6 = 7e4
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
using pii = array<int,2>;
const int mod=1000000007ll;
void solve(){
int n,m,Q,k;
cin>>n>>m>>Q>>k;
queue<int>q;
int vis[n];
memset(vis,-1,sizeof(vis));
for(int i=0;i<Q;i++){
int tem;
cin>>tem;
tem--;
q.push(tem);
vis[tem]=0;
}
vector<int>v[n];
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
x--,y--;
v[x].pb(y);
v[y].pb(x);
}
//cerr<<v[2].size()<<"\n";
while(q.size()){
int top=q.front();
q.pop();
//cerr<<top<<" doing\n";
for(int i:v[top]){
if(vis[i]==-1){
//cerr<<i<<" "<<vis[i]<<" ";
vis[i]=vis[top]+1;
q.push(i);
}
}
}
vector<int>days;
days.pb(0);
int now=k;
for(int i=2;*days.rbegin()<n;i++){
days.pb(*days.rbegin()+now);
now+=i*k;
}
//cerr<<"ok\n";
for(int i=0;i<n;i++){
//cerr<<vis[i]<<" "<<*days.rbegin()<<"\n";
cout<<lower_bound(days.begin(),days.end(),vis[i])-days.begin()<<" ";
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
#ifndef INTERACTIVE
freopen("in","r",stdin);
#endif
freopen("out","w",stdout);
#endif
int t=1;
//cin>>t;
while (t--)
{
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
9812 KB |
Output is correct |
2 |
Incorrect |
60 ms |
10404 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
10316 KB |
Output is correct |
2 |
Incorrect |
57 ms |
10068 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
9812 KB |
Output is correct |
2 |
Incorrect |
73 ms |
10432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
9528 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
9572 KB |
Output is correct |
2 |
Incorrect |
58 ms |
9784 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
9616 KB |
Output is correct |
2 |
Incorrect |
53 ms |
10064 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
9556 KB |
Output is correct |
2 |
Incorrect |
57 ms |
9296 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |