Submission #918894

#TimeUsernameProblemLanguageResultExecution timeMemory
918894NonozeBurza (COCI16_burza)C++17
0 / 160
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; #define int long long #define sz(x) (int)(x.size()) #define debug(x) cerr << (#x) << ": " << (x) << endl #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() int n, k, m; vector<vector<int>> adj; int dfs(int s, int lst) { if (sz(adj[s])<=2) return 1+(lst==-1?1:0); vector<int> a; for (auto u: adj[s]) { if (u==lst) continue; a.push_back(dfs(u, s)); } sort(rall(a)); return a[1]+1; } void solve() { cin >> n >> k; adj.resize(n); for (int i=0; i<n-1; i++) { int u, v; cin >> u >> v; u--, v--; adj[u].push_back(v); adj[v].push_back(u); } if (dfs(0, -1)<=k) cout << "DA" << endl; else cout << "NE" << endl; return; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int tt=1;// cin >> tt; while(tt--) 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...