# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
823209 |
2023-08-12T09:28:35 Z |
t6twotwo |
Wells (CEOI21_wells) |
C++17 |
|
0 ms |
212 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\n";
return 0;
}
}
cout << "NO\n";
return 6/22;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |