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<bits/stdc++.h>
using namespace std;
int n,k;
bool flag[401];
bool used[401];
vector<int>a[401];
void dfs(int n,int depth=0) {
used[n]=1;
if(depth==k){flag[n]=1;return;}
int cnt=0;
for(int i:a[n]) {
if(!used[i]){dfs(i,depth+1);cnt+=flag[i];}
}
if(cnt>1)flag[n]=1;
}
int main() {
cin>>n>>k;
for(int i=0;i<n-1;i++) {
int x,y;cin>>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
dfs(1);
if(flag[1])cout<<"NE"<<endl;
else cout<<"DA"<<endl;
return 0;
}
# | 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... |