Submission #823211

# Submission time Handle Problem Language Result Execution time Memory
823211 2023-08-12T09:29:06 Z t6twotwo Wells (CEOI21_wells) C++17
0 / 100
31 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<vector<int>> adj(N);
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for (int root = 0; root < N; root++) {
        vector<int> c(N);
        auto color = [&](auto f, int x, int p, int dep) -> void {
            if (dep % K == 0) {
                c[x] = 1;
            }
            for (int y : adj[x]) {
                if (y != p) {
                    f(f, y, x, dep + 1);
                }
            }
        };
        color(color, root, -1, 0);
        auto dfs = [&](auto dfs, int x, int p, int cnt, int dep) -> bool {
            if (dep == K - 1) {
                return cnt == 1;
            }
            for (int y : adj[x]) {
                if (y != p) {
                    if (!dfs(dfs, y, x, cnt + c[y], dep + 1)) {
                        return 0;
                    }
                }
            }
            return 1;
        };
        bool ok = 1;
        for (int i = 0; i < N; i++) {
            if (!dfs(dfs, i, -1, c[i], 0)) {
                ok = 0;
            }
        }
        if (ok) {
            cout << "YES\n1";
            return 0;
        }
    }
    cout << "NO\n0";
    return 6/22;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 2 ms 212 KB Output is partially correct
3 Partially correct 1 ms 212 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Correct 6 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 14 ms 332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Partially correct 1 ms 212 KB Output is partially correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 320 KB Output is correct
15 Partially correct 2 ms 212 KB Output is partially correct
16 Partially correct 1 ms 212 KB Output is partially correct
17 Partially correct 2 ms 320 KB Output is partially correct
18 Partially correct 1 ms 212 KB Output is partially correct
19 Partially correct 2 ms 212 KB Output is partially correct
20 Correct 19 ms 332 KB Output is correct
21 Partially correct 2 ms 212 KB Output is partially correct
22 Partially correct 1 ms 340 KB Output is partially correct
23 Partially correct 1 ms 212 KB Output is partially correct
24 Partially correct 1 ms 212 KB Output is partially correct
25 Partially correct 2 ms 212 KB Output is partially correct
26 Partially correct 1 ms 212 KB Output is partially correct
27 Partially correct 9 ms 336 KB Output is partially correct
28 Correct 21 ms 336 KB Output is correct
29 Partially correct 1 ms 212 KB Output is partially correct
30 Partially correct 2 ms 212 KB Output is partially correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Partially correct 1 ms 340 KB Output is partially correct
34 Correct 5 ms 224 KB Output is correct
35 Partially correct 1 ms 212 KB Output is partially correct
36 Partially correct 7 ms 328 KB Output is partially correct
37 Partially correct 1 ms 212 KB Output is partially correct
38 Partially correct 1 ms 212 KB Output is partially correct
39 Partially correct 1 ms 212 KB Output is partially correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Partially correct 4 ms 212 KB Output is partially correct
43 Partially correct 1 ms 212 KB Output is partially correct
44 Correct 7 ms 212 KB Output is correct
45 Partially correct 7 ms 212 KB Output is partially correct
46 Partially correct 1 ms 212 KB Output is partially correct
47 Partially correct 1 ms 212 KB Output is partially correct
48 Partially correct 3 ms 316 KB Output is partially correct
49 Incorrect 31 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 2 ms 212 KB Output is partially correct
3 Partially correct 1 ms 212 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Correct 6 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 14 ms 332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Partially correct 1 ms 212 KB Output is partially correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 320 KB Output is correct
15 Partially correct 2 ms 212 KB Output is partially correct
16 Partially correct 1 ms 212 KB Output is partially correct
17 Partially correct 2 ms 320 KB Output is partially correct
18 Partially correct 1 ms 212 KB Output is partially correct
19 Partially correct 2 ms 212 KB Output is partially correct
20 Correct 19 ms 332 KB Output is correct
21 Partially correct 2 ms 212 KB Output is partially correct
22 Partially correct 1 ms 340 KB Output is partially correct
23 Partially correct 1 ms 212 KB Output is partially correct
24 Partially correct 1 ms 212 KB Output is partially correct
25 Partially correct 2 ms 212 KB Output is partially correct
26 Partially correct 1 ms 212 KB Output is partially correct
27 Partially correct 9 ms 336 KB Output is partially correct
28 Correct 21 ms 336 KB Output is correct
29 Partially correct 1 ms 212 KB Output is partially correct
30 Partially correct 2 ms 212 KB Output is partially correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Partially correct 1 ms 340 KB Output is partially correct
34 Correct 5 ms 224 KB Output is correct
35 Partially correct 1 ms 212 KB Output is partially correct
36 Partially correct 7 ms 328 KB Output is partially correct
37 Partially correct 1 ms 212 KB Output is partially correct
38 Partially correct 1 ms 212 KB Output is partially correct
39 Partially correct 1 ms 212 KB Output is partially correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Partially correct 4 ms 212 KB Output is partially correct
43 Partially correct 1 ms 212 KB Output is partially correct
44 Correct 7 ms 212 KB Output is correct
45 Partially correct 7 ms 212 KB Output is partially correct
46 Partially correct 1 ms 212 KB Output is partially correct
47 Partially correct 1 ms 212 KB Output is partially correct
48 Partially correct 3 ms 316 KB Output is partially correct
49 Incorrect 31 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 2 ms 212 KB Output is partially correct
3 Partially correct 1 ms 212 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Correct 6 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 14 ms 332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Partially correct 1 ms 212 KB Output is partially correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 320 KB Output is correct
15 Partially correct 2 ms 212 KB Output is partially correct
16 Partially correct 1 ms 212 KB Output is partially correct
17 Partially correct 2 ms 320 KB Output is partially correct
18 Partially correct 1 ms 212 KB Output is partially correct
19 Partially correct 2 ms 212 KB Output is partially correct
20 Correct 19 ms 332 KB Output is correct
21 Partially correct 2 ms 212 KB Output is partially correct
22 Partially correct 1 ms 340 KB Output is partially correct
23 Partially correct 1 ms 212 KB Output is partially correct
24 Partially correct 1 ms 212 KB Output is partially correct
25 Partially correct 2 ms 212 KB Output is partially correct
26 Partially correct 1 ms 212 KB Output is partially correct
27 Partially correct 9 ms 336 KB Output is partially correct
28 Correct 21 ms 336 KB Output is correct
29 Partially correct 1 ms 212 KB Output is partially correct
30 Partially correct 2 ms 212 KB Output is partially correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Partially correct 1 ms 340 KB Output is partially correct
34 Correct 5 ms 224 KB Output is correct
35 Partially correct 1 ms 212 KB Output is partially correct
36 Partially correct 7 ms 328 KB Output is partially correct
37 Partially correct 1 ms 212 KB Output is partially correct
38 Partially correct 1 ms 212 KB Output is partially correct
39 Partially correct 1 ms 212 KB Output is partially correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Partially correct 4 ms 212 KB Output is partially correct
43 Partially correct 1 ms 212 KB Output is partially correct
44 Correct 7 ms 212 KB Output is correct
45 Partially correct 7 ms 212 KB Output is partially correct
46 Partially correct 1 ms 212 KB Output is partially correct
47 Partially correct 1 ms 212 KB Output is partially correct
48 Partially correct 3 ms 316 KB Output is partially correct
49 Incorrect 31 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Partially correct 2 ms 212 KB Output is partially correct
3 Partially correct 1 ms 212 KB Output is partially correct
4 Partially correct 1 ms 212 KB Output is partially correct
5 Partially correct 1 ms 212 KB Output is partially correct
6 Partially correct 1 ms 212 KB Output is partially correct
7 Correct 6 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 14 ms 332 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Partially correct 1 ms 212 KB Output is partially correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 320 KB Output is correct
15 Partially correct 2 ms 212 KB Output is partially correct
16 Partially correct 1 ms 212 KB Output is partially correct
17 Partially correct 2 ms 320 KB Output is partially correct
18 Partially correct 1 ms 212 KB Output is partially correct
19 Partially correct 2 ms 212 KB Output is partially correct
20 Correct 19 ms 332 KB Output is correct
21 Partially correct 2 ms 212 KB Output is partially correct
22 Partially correct 1 ms 340 KB Output is partially correct
23 Partially correct 1 ms 212 KB Output is partially correct
24 Partially correct 1 ms 212 KB Output is partially correct
25 Partially correct 2 ms 212 KB Output is partially correct
26 Partially correct 1 ms 212 KB Output is partially correct
27 Partially correct 9 ms 336 KB Output is partially correct
28 Correct 21 ms 336 KB Output is correct
29 Partially correct 1 ms 212 KB Output is partially correct
30 Partially correct 2 ms 212 KB Output is partially correct
31 Correct 3 ms 320 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Partially correct 1 ms 340 KB Output is partially correct
34 Correct 5 ms 224 KB Output is correct
35 Partially correct 1 ms 212 KB Output is partially correct
36 Partially correct 7 ms 328 KB Output is partially correct
37 Partially correct 1 ms 212 KB Output is partially correct
38 Partially correct 1 ms 212 KB Output is partially correct
39 Partially correct 1 ms 212 KB Output is partially correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Partially correct 4 ms 212 KB Output is partially correct
43 Partially correct 1 ms 212 KB Output is partially correct
44 Correct 7 ms 212 KB Output is correct
45 Partially correct 7 ms 212 KB Output is partially correct
46 Partially correct 1 ms 212 KB Output is partially correct
47 Partially correct 1 ms 212 KB Output is partially correct
48 Partially correct 3 ms 316 KB Output is partially correct
49 Incorrect 31 ms 212 KB Output isn't correct
50 Halted 0 ms 0 KB -