Submission #1127969

#TimeUsernameProblemLanguageResultExecution timeMemory
1127969FucKanhBurza (COCI16_burza)C++20
0 / 160
1 ms324 KiB
#include<bits/stdc++.h> #define ll long long #define int ll #define pii pair<int,int> using namespace std; const int maxn = 500; int n,k; int pa[maxn], h[maxn], need[maxn]; vector<int> node[maxn], a[maxn]; void dfs(int u) { node[h[u]].push_back(u); for(int v : a[u]) { if (v==pa[u]) continue; pa[v] = u; h[v] = h[u] + 1; dfs(v); } } void solve() { cin >> n >> k; k--; for (int i = 1; i < n; i++) { int x,y; cin >> x >> y; a[x].push_back(y); a[y].push_back(x); } dfs(1); for (int val : node[k+1]) need[val] = 1; for (int i = k; i >= 0; i--) { for (int u : node[i]) { need[u]=n; for (int j = 0; j <= n; j++) { int mx = 0, use = 0; for (int v : a[u]) if (v != pa[u]) { if (need[v] > j) use++; else mx = max(mx, need[v]); } if (mx + use <= j) { need[u] = j; break; } } } } if (need[1] <= k) { cout << "DA"; } else { cout << "NE"; } } signed main() { cin.tie(0) -> sync_with_stdio(0); solve(); return 0; }
#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...