제출 #860212

#제출 시각아이디문제언어결과실행 시간메모리
860212HakiersBurza (COCI16_burza)C++17
0 / 160
1 ms572 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...