Submission #901644

#TimeUsernameProblemLanguageResultExecution timeMemory
901644KeysBurza (COCI16_burza)C++14
0 / 160
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t typedef vector<int> vi; #define pb push_back #define f first #define s second #define all(x) x.begin(), x.end() #define endl '\n' #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define ROF(i, a, b) for (int i = (a); i >= (b); i--) #define trav(i, a) for (auto& i : a) const int N = 405; vi g[N]; int dfs(int u, int p) { vi x; trav(v, g[u]) if (v != p) x.pb(dfs(v, u)); x.pb(0); x.pb(0); sort(all(x)); reverse(all(x)); return x[1] + 1; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; FOR(i, 0, n - 1) { int u, v; cin >> u >> v; g[u].pb(v); g[v].pb(u); } cout << (dfs(1, 0) <= k ? "DA" : "NE") << endl; } /* hori san Claim: If k^2 >= n, then then the answer is yes. */
#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...