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>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#define mp make_pair
#define ios ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define bug(str, x) cerr << "# " << str << " : " << x << '\n'
#define here(x) cerr << "here " << x << '\n'
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
const int inf = 1e9;
int n, k;
vector<int> G[maxn];
bool dfs(int v, int p, int h){
if(h == k){
return true;
}
int res = 0;
for(int u : G[v]){
if(u != p){
res += dfs(u, v, h + 1);
}
}
return res > 1;
}
int main(){
ios;
cin >> n >> k;
for(int i = 0; i < n - 1; i ++){
int u, v;
cin >> u >> v;
G[--u].push_back(--v);
G[v].push_back(u);
}
cout << (dfs(0, -1, 0) ? "NE" : "DA");
}
# | 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... |