/*
I n u z u k a S h i n o -w-
*/
#include <bits/stdc++.h>
using namespace std;
#define FILE(name) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout)
#define FOR(i, x, n) for (int i = x; i <= n; ++i)
#define FOD(i, x, n) for (int i = x; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define bit(n, i) ((n >> i) & 1)
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int, int>
const int N = 1e3 + 5;
const int M = 1e5 + 5;
const int MOD = 1e9 + 7;
bool vis[M];
int n, m, q, k;
int d[M], ans[M];
vector<int> a[M];
vector<int> knowed;
void bfs(){
queue<int> q;
for (int x: knowed) q.push(x);
while (q.size()){
int u = q.front(); q.pop();
for (int v: a[u]){
if (vis[v]) continue;
vis[v] = 1;
d[v] = d[u] + 1;
q.push(v);
}
}
}
int main(){
cin.tie(0) -> sync_with_stdio(0);
cin >>n >>m >>q >>k;
while (q--){
int x; cin >>x;
vis[x] = 1;
knowed.pb(x);
}
while (m--){
int u, v; cin >>u >>v;
a[u].pb(v); a[v].pb(u);
}
bfs();
int step = 1, x = 1;
while (step < n){
FOR(d, step, min(n, step + x * k))
ans[d] = x;
step += x * k; ++x;
}
FOR(u, 1, n) cout <<ans[d[u]] <<' ';
return 0;
}
# | 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... |