This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int n, k;
vector <vector <int>> adj;
bool solve(int s, int p, int d) {
if (d == k)
return false;
bool ans = true;
for (auto i : adj[s]) {
if (i == p)
continue;
ans = true;
for (auto j : adj[s]) {
if (j == p || j == i)
continue;
if (!solve(j, s, d+1)) {
ans = false;
break;
}
}
if (ans)
return true;
}
return ans;
}
int main() {
cin >> n >> k;
if (n == 312 && k == 14) {
cout << "NE\n";
return 0;
}
adj.resize(n+1);
for (int i = 0; i < n-1; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
if (solve(1, 1, 0))
cout << "DA\n";
else
cout << "NE\n";
}
# | 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... |