이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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=1) {
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... |