Submission #581659

#TimeUsernameProblemLanguageResultExecution timeMemory
581659BackNoobBurza (COCI16_burza)C++14
0 / 160
1095 ms23892 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define MASK(i) (1LL << (i)) #define ull unsigned long long #define ld long double #define pb push_back #define all(x) (x).begin() , (x).end() #define BIT(x , i) ((x >> (i)) & 1) #define TASK "task" #define sz(s) (int) (s).size() using namespace std; const int mxN = 5e5 + 227; const int inf = 1e9 + 277; const int mod = 1e9 + 7; const ll infll = 1e18 + 7; const int base = 307; const int LOG = 20; template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } int n; int k; int depth[mxN]; vector<int> adj[mxN]; vector<int> node[mxN]; bool ok = true; bool ban[mxN]; void dfs(int u, int par) { for(int v : adj[u]) { if(v == par) continue; depth[v] = depth[u] + 1; dfs(v, u); } } void getans(int u, int par) { if(depth[u] == k) ok = false; for(int v : adj[u]) { if(v == par || ban[v] == true) continue; getans(v, u); } } void gen(int x) { if(sz(node[x]) == 0) { ok = true; getans(1, -1); if(ok == true) { cout << "DA" << endl; exit(0); } return; } for(auto it : node[x]) { ban[it] = true; gen(x + 1); ban[it] = false; } } void solve() { cin >> n >> k; for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } dfs(1, -1); for(int i = 1; i <= n; i++) node[depth[i]].pb(i); gen(1); cout << "NE"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(TASK".inp" , "r" , stdin); //freopen(TASK".out" , "w" , stdout); int tc = 1; //cin >> tc; while(tc--) { 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...