# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
880090 |
2023-11-28T17:25:18 Z |
anton |
Burza (COCI16_burza) |
C++17 |
|
1 ms |
348 KB |
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<vector<int>> ch;
void dfs(int u, int anc){
for(auto v:adj[u]){
if(v!=anc){
ch[u].push_back(v);
dfs(v, u);
}
}
}
int dp(int u){
int best = -1;
int s_best = -1;
for(auto e: ch[u]){
auto cur = dp(e);
if(cur>=best){
s_best = best;
best = cur;
}
else if(cur>=s_best){
s_best = cur;
}
}
return s_best+1;
}
signed main(){
int n,k;
cin>>n>>k;
adj.resize(n);
ch.resize(n);
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);
}
dfs(0, -1);
int res = dp(0);
//cout<<res<<endl;
if(k>res){
cout<<"DA"<<endl;
}
else{
cout<<"NE"<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |