#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define PB push_back
using namespace std;
const int N = 100100;
const int oo = 2e9;
queue<int> q;
vector<int> g[N];
int n, m, qq, k, dst[N];
int answer(int vl){
int sum = 0, nw = k, kol = 0;
while (vl > sum){
sum += nw;
nw += k;
kol++;
}
return kol;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
cin >> n >> m >> qq >> k;
fill(dst, dst + n, oo);
for (int i = 0; i < qq; i++){
int x; cin >> x;
x--;
dst[x] = 0;
q.push(x);
}
for (int i = 0; i < m; i++){
int x, y; cin >> x >> y;
x--; y--;
g[x].PB(y);
g[y].PB(x);
}
while (sz(q)){
int v = q.front(); q.pop();
for (int u : g[v])
if (dst[u] == oo){
dst[u] = dst[v] + 1;
q.push(u);
}
}
for (int i = 0; i < n; i++)
cout << answer(dst[i]) << " ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
9464 KB |
Output is correct |
2 |
Correct |
113 ms |
9976 KB |
Output is correct |
3 |
Correct |
130 ms |
10368 KB |
Output is correct |
4 |
Correct |
86 ms |
8952 KB |
Output is correct |
5 |
Correct |
97 ms |
9176 KB |
Output is correct |
6 |
Correct |
115 ms |
10232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
9960 KB |
Output is correct |
2 |
Correct |
99 ms |
9720 KB |
Output is correct |
3 |
Correct |
106 ms |
9976 KB |
Output is correct |
4 |
Correct |
119 ms |
10016 KB |
Output is correct |
5 |
Correct |
98 ms |
9848 KB |
Output is correct |
6 |
Correct |
96 ms |
9592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
9592 KB |
Output is correct |
2 |
Correct |
105 ms |
9976 KB |
Output is correct |
3 |
Correct |
109 ms |
10232 KB |
Output is correct |
4 |
Correct |
104 ms |
9976 KB |
Output is correct |
5 |
Correct |
97 ms |
9336 KB |
Output is correct |
6 |
Correct |
98 ms |
9592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
9080 KB |
Output is correct |
2 |
Correct |
115 ms |
9868 KB |
Output is correct |
3 |
Correct |
114 ms |
9976 KB |
Output is correct |
4 |
Correct |
96 ms |
9392 KB |
Output is correct |
5 |
Correct |
90 ms |
9080 KB |
Output is correct |
6 |
Correct |
103 ms |
9592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
9208 KB |
Output is correct |
2 |
Correct |
94 ms |
9464 KB |
Output is correct |
3 |
Correct |
92 ms |
9464 KB |
Output is correct |
4 |
Correct |
96 ms |
9336 KB |
Output is correct |
5 |
Correct |
95 ms |
9468 KB |
Output is correct |
6 |
Correct |
89 ms |
9464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
9208 KB |
Output is correct |
2 |
Correct |
96 ms |
9464 KB |
Output is correct |
3 |
Correct |
99 ms |
9528 KB |
Output is correct |
4 |
Correct |
99 ms |
9720 KB |
Output is correct |
5 |
Correct |
94 ms |
9336 KB |
Output is correct |
6 |
Correct |
92 ms |
9592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
9368 KB |
Output is correct |
2 |
Correct |
86 ms |
9080 KB |
Output is correct |
3 |
Correct |
108 ms |
10104 KB |
Output is correct |
4 |
Correct |
91 ms |
9336 KB |
Output is correct |
5 |
Correct |
104 ms |
9720 KB |
Output is correct |
6 |
Correct |
104 ms |
10232 KB |
Output is correct |