/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 18;
int n, m, qq, k;
vector<int> g[N];
void solve(){
cin >> n >> m >> qq >> k;
vector<int> dist(n+1, MOD);
vector<int> vis(n+1, 0);
queue<int> q;
for(int i = 0; i < qq; ++i){
int x; cin >> x;
dist[x] = 0;
q.push(x);
vis[x] = 1;
}
for(int i= 0; i < m; ++i){
int u, v; cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
while(!q.empty()){
int v = q.front(); q.pop();
for(int u: g[v]){
if(!vis[u]){
dist[u] = dist[v]+1;
q.push(u);
vis[u] = 1;
}
}
}
vector<int> ans(N);
ans[0] = 0;
int cur = k, last = 1, lastt = 0;
for(int i = 1; i <= n; ++i){
for(int j = 0; j < cur; ++j){
ans[last] = ans[lastt] + 1;
last++;
}
lastt = last - 1;
cur += k;
if(lastt > n) break;
}
// for(int i = 1; i <= n; ++i) cout << ans[i] << ' ';
// en;
for(int i = 1; i <= n; ++i){
cout << ans[dist[i]] << ' ';
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// cin >> tt;
while(tt--){
solve();
// en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
birmingham.cpp: In function 'int main()':
birmingham.cpp:67:15: warning: unused variable 'aa' [-Wunused-variable]
67 | int tt = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
27740 KB |
Output is correct |
2 |
Correct |
6 ms |
27792 KB |
Output is correct |
3 |
Correct |
7 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
27736 KB |
Output is correct |
2 |
Correct |
8 ms |
27740 KB |
Output is correct |
3 |
Correct |
7 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
27740 KB |
Output is correct |
2 |
Correct |
6 ms |
27740 KB |
Output is correct |
3 |
Correct |
6 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
27736 KB |
Output is correct |
2 |
Correct |
6 ms |
27776 KB |
Output is correct |
3 |
Correct |
6 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
27776 KB |
Output is correct |
2 |
Correct |
7 ms |
27776 KB |
Output is correct |
3 |
Correct |
6 ms |
27740 KB |
Output is correct |
4 |
Correct |
7 ms |
27784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
27740 KB |
Output is correct |
2 |
Correct |
6 ms |
27740 KB |
Output is correct |
3 |
Correct |
7 ms |
27740 KB |
Output is correct |
4 |
Correct |
7 ms |
27736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
27740 KB |
Output is correct |
2 |
Correct |
6 ms |
27740 KB |
Output is correct |
3 |
Correct |
7 ms |
27736 KB |
Output is correct |
4 |
Correct |
6 ms |
27740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
32924 KB |
Output is correct |
2 |
Correct |
62 ms |
33108 KB |
Output is correct |
3 |
Correct |
57 ms |
33112 KB |
Output is correct |
4 |
Correct |
50 ms |
32608 KB |
Output is correct |
5 |
Correct |
50 ms |
32848 KB |
Output is correct |
6 |
Correct |
70 ms |
33180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
56 ms |
33252 KB |
Output is correct |
2 |
Correct |
55 ms |
33104 KB |
Output is correct |
3 |
Correct |
74 ms |
33248 KB |
Output is correct |
4 |
Correct |
65 ms |
33104 KB |
Output is correct |
5 |
Correct |
55 ms |
32980 KB |
Output is correct |
6 |
Correct |
57 ms |
32884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
33288 KB |
Output is correct |
2 |
Correct |
80 ms |
33256 KB |
Output is correct |
3 |
Correct |
60 ms |
33108 KB |
Output is correct |
4 |
Correct |
61 ms |
33336 KB |
Output is correct |
5 |
Correct |
51 ms |
32876 KB |
Output is correct |
6 |
Correct |
52 ms |
32852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
32904 KB |
Output is correct |
2 |
Correct |
56 ms |
33108 KB |
Output is correct |
3 |
Correct |
56 ms |
33116 KB |
Output is correct |
4 |
Correct |
51 ms |
32848 KB |
Output is correct |
5 |
Correct |
50 ms |
32596 KB |
Output is correct |
6 |
Correct |
52 ms |
32716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
32848 KB |
Output is correct |
2 |
Correct |
52 ms |
32844 KB |
Output is correct |
3 |
Correct |
54 ms |
32852 KB |
Output is correct |
4 |
Correct |
50 ms |
32824 KB |
Output is correct |
5 |
Correct |
52 ms |
32880 KB |
Output is correct |
6 |
Correct |
49 ms |
32848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
32824 KB |
Output is correct |
2 |
Correct |
52 ms |
33172 KB |
Output is correct |
3 |
Correct |
52 ms |
32820 KB |
Output is correct |
4 |
Correct |
54 ms |
33104 KB |
Output is correct |
5 |
Correct |
50 ms |
32852 KB |
Output is correct |
6 |
Correct |
51 ms |
32848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
32852 KB |
Output is correct |
2 |
Correct |
48 ms |
32636 KB |
Output is correct |
3 |
Correct |
59 ms |
33104 KB |
Output is correct |
4 |
Correct |
50 ms |
32836 KB |
Output is correct |
5 |
Correct |
53 ms |
32860 KB |
Output is correct |
6 |
Correct |
56 ms |
33108 KB |
Output is correct |