# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
860212 |
2023-10-12T07:17:10 Z |
Hakiers |
Burza (COCI16_burza) |
C++17 |
|
1 ms |
572 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 7;
vector<int> G[MAXN];
int dp[MAXN];
int n, k;
void dfs(int v, int p){
int maxu = 0;
for(auto u : G[v]){
if(u == p) continue;
dfs(u, v);
if(dp[u] > dp[maxu]) maxu = u;
}
int maxdp = -1;
for(auto u : G[v]){
if(u == p || u == maxu) continue;
maxdp = max(maxdp, dp[u]);
}
dp[v] = maxdp+1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for(int i = 1; i < n; i++){
int a, b;
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
dp[0] = -1;
dfs(1, 1);
if(dp[1] < k)
cout << "DA \n";
else cout << "NE \n";
}
# |
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 |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
572 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 |
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 |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |