이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define ull unsigned ll
using namespace std;
vector<long> branches[401];
vector<long> children[401];
long parents[401];
long N,K;
long dp[401]={};
long depth = -1;
void dfs(long u,long parent){
depth++;
parents[u] = parent;
for (auto v:branches[u]){
if (v!=parent){
children[u].push_back(v);
dfs(v,u);
}
}
if (depth==K){
dp[u] = LONG_MAX;
}
else if (children[u].size()<2){
dp[u] = 0;
}
else{
//sort(children[u].begin(),children[u].end(),greater<>());
for (auto v:children[u]){
if (dp[v] != 0) dp[u]++;
}
if (dp[u]!=0) dp[u]--;
}
depth--;
return;
}
int main(){
cin>>N>>K;
for(long i = 1;i<=N-1;i++){
long u,v;
cin>>u>>v;
branches[u].push_back(v);
branches[v].push_back(u);
}
dfs(1,-1);
if (dp[1] == 0) cout<<"DA"; else cout<<"NE";
}
# | 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... |