Submission #47823

#TimeUsernameProblemLanguageResultExecution timeMemory
47823tieunhiBurza (COCI16_burza)C++14
0 / 160
2 ms896 KiB
#include <bits/stdc++.h> #define PB push_back #define N 405 using namespace std; int n, k; vector<int> g[N]; int DFS(int u, int p) { int f1 = 0, f2 = 0; for (auto v : g[u]) { if (v == p) continue; int z = DFS(v, u); if (z >= f1) { f2 = f1; f1 = z; } else if (z > f2) f2 = z; } return f2 + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("INP.TXT", "r", stdin); cin >> n >> k; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; g[u].PB(v); g[v].PB(u); } int res = DFS(1, -1); if (res <= k) cout <<"DA"; else cout <<"NE"; }
#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...