/**
* author: kututay
* created: 06.09.2023 15:06:26
**/
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/Users/kutay/CP/templates/debug.h"
#else
#define debug(...) void(38)
#endif
const int inf = 1e9;
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, qu, k; cin >> n >> m >> qu >> k;
vector<int> a(qu), ans(n, inf); for (int &x : a) cin >> x, x--;
vector<vector<int>> g(n);
for (int i = 0; i < m; i++) {
int x, y; cin >> x >> y, x--, y--;
g[x].emplace_back(y);
g[y].emplace_back(x);
}
queue<pair<int, int>> q;
for (int x : a) {
q.emplace(x, 0);
}
while (q.size()) {
auto [node, depth] = q.front();
q.pop();
if (ans[node] != inf) continue;
ans[node] = round(sqrt(ceil(depth * 2.0 / k)));
for (auto next : g[node]) {
q.emplace(next, depth + 1);
}
}
for (int &x : ans) cout << x << " ";
cout << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
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 |
600 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 |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
8528 KB |
Output is correct |
2 |
Correct |
60 ms |
8532 KB |
Output is correct |
3 |
Correct |
59 ms |
9564 KB |
Output is correct |
4 |
Correct |
49 ms |
8008 KB |
Output is correct |
5 |
Correct |
89 ms |
8128 KB |
Output is correct |
6 |
Correct |
54 ms |
9812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
8656 KB |
Output is correct |
2 |
Correct |
62 ms |
8692 KB |
Output is correct |
3 |
Correct |
56 ms |
9168 KB |
Output is correct |
4 |
Correct |
70 ms |
8796 KB |
Output is correct |
5 |
Correct |
57 ms |
8724 KB |
Output is correct |
6 |
Correct |
51 ms |
9440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
8408 KB |
Output is correct |
2 |
Correct |
55 ms |
8628 KB |
Output is correct |
3 |
Correct |
73 ms |
9556 KB |
Output is correct |
4 |
Correct |
52 ms |
8788 KB |
Output is correct |
5 |
Correct |
70 ms |
8160 KB |
Output is correct |
6 |
Correct |
50 ms |
9044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
8016 KB |
Output is correct |
2 |
Correct |
47 ms |
8540 KB |
Output is correct |
3 |
Correct |
94 ms |
9296 KB |
Output is correct |
4 |
Correct |
56 ms |
8308 KB |
Output is correct |
5 |
Correct |
54 ms |
8008 KB |
Output is correct |
6 |
Correct |
98 ms |
8964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
7976 KB |
Output is correct |
2 |
Correct |
53 ms |
8504 KB |
Output is correct |
3 |
Correct |
54 ms |
8784 KB |
Output is correct |
4 |
Correct |
48 ms |
8220 KB |
Output is correct |
5 |
Correct |
78 ms |
8420 KB |
Output is correct |
6 |
Correct |
46 ms |
9044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
8048 KB |
Output is correct |
2 |
Correct |
49 ms |
8284 KB |
Output is correct |
3 |
Correct |
57 ms |
8852 KB |
Output is correct |
4 |
Correct |
70 ms |
8532 KB |
Output is correct |
5 |
Correct |
48 ms |
8136 KB |
Output is correct |
6 |
Correct |
46 ms |
9308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
8220 KB |
Output is correct |
2 |
Correct |
45 ms |
7868 KB |
Output is correct |
3 |
Correct |
57 ms |
9536 KB |
Output is correct |
4 |
Correct |
48 ms |
8272 KB |
Output is correct |
5 |
Correct |
55 ms |
8528 KB |
Output is correct |
6 |
Correct |
53 ms |
9784 KB |
Output is correct |