#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
using namespace std;
void solve(){
int n,m,q,k; cin >> n >> m >> q >> k;
vi edges[n+1];
int dist[n+1], vis[n+1];
for(int i=1; i<=n; i++){
dist[i]=-1;
vis[i]=0;
}
queue<int> que;
for(int i=1; i<=q; i++){
int a; cin >> a;
que.push(a);
dist[a]=0;
}
for(int i=1; i<=m; i++){
int a,b; cin >> a >> b;
edges[a].pb(b);
edges[b].pb(a);
}
while(que.size()>0){
int f=que.front();
que.pop();
vis[f]=1;
for(auto nex:edges[f]){
if(vis[nex]) continue;
vis[nex]=1;
//cerr << f spc nex << endl;
que.push(nex);
dist[nex]=dist[f]+1;
}
}
for(int i=1; i<=n; i++){
int ans=0;
int cur=1;
//cerr << dist[i] << endl;
while(dist[i]>=(cur*k)){
dist[i]-=(cur*k);
ans++;
cur++;
}
if(dist[i]!=0) ans++;
cout << ans << " ";
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
10716 KB |
Output is correct |
2 |
Correct |
60 ms |
11092 KB |
Output is correct |
3 |
Incorrect |
73 ms |
11564 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
11060 KB |
Output is correct |
2 |
Correct |
61 ms |
10836 KB |
Output is correct |
3 |
Incorrect |
63 ms |
11092 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
10796 KB |
Output is correct |
2 |
Correct |
64 ms |
11368 KB |
Output is correct |
3 |
Incorrect |
60 ms |
11348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
10068 KB |
Output is correct |
2 |
Correct |
55 ms |
10908 KB |
Output is correct |
3 |
Incorrect |
61 ms |
11092 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
10168 KB |
Output is correct |
2 |
Correct |
52 ms |
10576 KB |
Output is correct |
3 |
Incorrect |
59 ms |
10580 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
10324 KB |
Output is correct |
2 |
Correct |
56 ms |
10748 KB |
Output is correct |
3 |
Incorrect |
54 ms |
10492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
10332 KB |
Output is correct |
2 |
Correct |
50 ms |
10096 KB |
Output is correct |
3 |
Incorrect |
61 ms |
11324 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |