#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;
const int inf = 2e18 + 5;
const int N = 5e3 + 5;
const int mod = 998244353;
int32_t main(){
//freopen("in.txt","r", stdin);
int n, m, q, k;
cin>>n>>m>>q>>k;
vector<int> st(q);
vector<int> dis(n+1, mod);
for(int i = 0; i < q; i++){
cin>>st[i];
dis[st[i]] = 0;
}
vector<int> adj[n+1];
for(int i = 0; i < m; i++){
int u, v;
cin>>u>>v;
adj[u].pb(v);
adj[v].pb(u);
}
queue<int> qq;
vector<int> vis(n+1);
for(int i = 0; i < q; i++){
qq.push(st[i]);
vis[st[i]] = 1;
}
while(!qq.empty()){
int x = qq.front();
qq.pop();
for(auto itr: adj[x]){
if(!vis[itr]){
vis[itr] = 1;
dis[itr] = dis[x] + 1, dis[itr];
//cout<<itr<<" "<<dis[itr]<<endl;
qq.push(itr);
}
}
}
for(int i = 1; i <= n; i++){
int x = dis[i], ans = 0, kk = k;
while(x > 0){
x -= kk;
kk += k;
ans++;
}
cout<<ans<<" ";
}
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
372 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
124 ms |
10636 KB |
Output is correct |
2 |
Correct |
113 ms |
11048 KB |
Output is correct |
3 |
Correct |
122 ms |
11648 KB |
Output is correct |
4 |
Correct |
104 ms |
10020 KB |
Output is correct |
5 |
Correct |
97 ms |
10156 KB |
Output is correct |
6 |
Correct |
121 ms |
11564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
117 ms |
11088 KB |
Output is correct |
2 |
Correct |
105 ms |
10836 KB |
Output is correct |
3 |
Correct |
115 ms |
11092 KB |
Output is correct |
4 |
Correct |
112 ms |
11088 KB |
Output is correct |
5 |
Correct |
124 ms |
10852 KB |
Output is correct |
6 |
Correct |
113 ms |
10892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
101 ms |
10608 KB |
Output is correct |
2 |
Correct |
111 ms |
11272 KB |
Output is correct |
3 |
Correct |
127 ms |
11404 KB |
Output is correct |
4 |
Correct |
116 ms |
11260 KB |
Output is correct |
5 |
Correct |
103 ms |
10404 KB |
Output is correct |
6 |
Correct |
130 ms |
11120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
95 ms |
10060 KB |
Output is correct |
2 |
Correct |
103 ms |
10716 KB |
Output is correct |
3 |
Correct |
112 ms |
11256 KB |
Output is correct |
4 |
Correct |
116 ms |
10948 KB |
Output is correct |
5 |
Correct |
95 ms |
10236 KB |
Output is correct |
6 |
Correct |
110 ms |
10912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
93 ms |
10272 KB |
Output is correct |
2 |
Correct |
103 ms |
10672 KB |
Output is correct |
3 |
Correct |
101 ms |
10576 KB |
Output is correct |
4 |
Correct |
99 ms |
10324 KB |
Output is correct |
5 |
Correct |
104 ms |
10588 KB |
Output is correct |
6 |
Correct |
135 ms |
10900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
10352 KB |
Output is correct |
2 |
Correct |
114 ms |
10692 KB |
Output is correct |
3 |
Correct |
106 ms |
10700 KB |
Output is correct |
4 |
Correct |
123 ms |
10844 KB |
Output is correct |
5 |
Correct |
98 ms |
10268 KB |
Output is correct |
6 |
Correct |
109 ms |
10948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
10468 KB |
Output is correct |
2 |
Correct |
105 ms |
9992 KB |
Output is correct |
3 |
Correct |
118 ms |
11388 KB |
Output is correct |
4 |
Correct |
99 ms |
10636 KB |
Output is correct |
5 |
Correct |
100 ms |
10652 KB |
Output is correct |
6 |
Correct |
128 ms |
12004 KB |
Output is correct |