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>
#define mod 1000000007
typedef long long ll;
using namespace std;
int n, m;
list<int> adj[400];
multiset<int> sets[400];
int f(int ata, int node){
//cout << "f(" << ata << ", " << node << ")\n";
for (list<int>::iterator it = adj[node].begin(); it != adj[node].end(); ++it){
if ((*it) == ata) continue;
sets[node].insert(f(node, *it));
}
if (sets[node].size() < 2) return 0;
multiset<int>::iterator it = sets[node].end();
advance(it, -2);
return 1+(*it);
}
int main(){
//freopen("baskent.gir", "r", stdin);
cin >> n >> m;
for (int i = 0; i < n-1; i++){
int a, b;
cin >> a >> b;
a--; b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
int ans = f(-1, 0);
if (ans < m) cout << "DA" << endl;
else cout << "NE" << endl;
}
# | 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... |