Submission #852147

#TimeUsernameProblemLanguageResultExecution timeMemory
852147overwatch9Burza (COCI16_burza)C++17
0 / 160
1 ms348 KiB
#include <iostream> #include <vector> using namespace std; int n, k; vector <vector <int>> adj; const int maxn = 400 + 1; bool solve(int s, int p, int d) { if (d == k) return false; if (adj[s].size() == 1 && s != p) return true; for (auto i : adj[s]) { if (i == p) continue; bool ans = true; for (auto j : adj[s]) { if (j == p || j == i) continue; ans &= solve(j, s, d+1); } if (ans) return true; } return false; } int main() { cin >> n >> k; adj.resize(n+1); for (int i = 0; i < n-1; i++) { int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } if (solve(1, 1, 0)) cout << "DA\n"; else 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...