This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* 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 (stderr)
birmingham.cpp: In function 'int main()':
birmingham.cpp:67:15: warning: unused variable 'aa' [-Wunused-variable]
67 | int tt = 1, aa;
| ^~
# | 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... |