Submission #248765

#TimeUsernameProblemLanguageResultExecution timeMemory
248765egekabasBurza (COCI16_burza)C++14
0 / 160
1 ms384 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; vector<int> g[500]; int p[500]; int n, k; vector<int> vec; void dfs(int v, int d){ if(d == k){ vec.pb(v); return; } for(auto u : g[v]) if(u != p[v]){ p[u] = v; dfs(u, d+1); } } int cnt[500]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); cin >> n >> k; for(int i = 0; i < n-1; ++i){ int a, b; cin >> a >> b; g[a].pb(b); g[b].pb(a); } dfs(1, 0); while(k--){ for(int i = 1; i <= n; ++i) cnt[i] = 0; for(auto u : vec){ cnt[p[u]]++;; } vector<int> newvec; int av = 1; for(auto u : vec){ if(cnt[p[u]] == 1 && av) av = 0; else{ if(cnt[p[u]] != -1){ newvec.pb(p[u]); cnt[p[u]] = -1; } } } if(newvec.size() == 0){ cout << "DA\n"; return 0; } vec = newvec; } 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...