Submission #885638

#TimeUsernameProblemLanguageResultExecution timeMemory
885638sanmaBurza (COCI16_burza)C++14
64 / 160
95 ms386148 KiB
// ----------------------------------------------------------------------------------------------------- // | | // | ngungungu ngungungu ngu ngu ngungu ngungungu ngungungu | // | ngu ngu nguu ngu ngu ngu ngu nguuu nguuu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu nguuu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu nguuu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu ngungungu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu nguuu ngu ngu ngu ngu | // | ngu ngu nguu ngu ngu ngu ngu ngu ngu nguuu ngu ngu ngu ngu ngu | // | ngungungu ngungungu ngu ngu ngu ngu ngu ngu ngu ngu | // | | // ----------------------------------------------------------------------------------------------------- // ONLINE_JUDGE #include<bits/stdc++.h> #define f(i,a,b) for(int i = (a) , _b = (b) ; i <= _b ;i ++) #define F first #define S second //#define int long long #define pii pair<int, int> #define piii pair<int, pair<int, int>> #define piiii pair<pair<int, int>, pair<int, int>> #define minimize(x,y) x = (x > y ? y : x) #define maximize(x,y) x = (x < y ? y : x) using namespace std; const int maxn = 409; const int mod = 1e9 + 7; int n, k; vector<int> a[maxn]; int h[maxn], maxf[maxn]; int tin[maxn], tout[maxn], timef; vector<int> v; bool dp[maxn][(1 << 20) + 1]; void pre(int x, int pX){ maxf[x] = h[x]; if(h[x] == k) return; for(auto y : a[x]){ if(y != pX){ h[y] = h[x] + 1; pre(y, x); maximize(maxf[x], maxf[y]); } } } void dfs(int x, int pX){ tin[x] = timef ++; v.push_back(x); for(auto y : a[x]){ if(y != pX && maxf[y] == k){ dfs(y, x); } } tout[x] = timef; } int32_t main() { ios_base :: sync_with_stdio(false); cin.tie(0); cin >> n >> k; f(i, 1, n - 1){ int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } if(k >= 20){ cout << "DA"; return 0; } pre(1, 0); dfs(1, 0); f(i, 0, (1 << 20) - 1) dp[timef][i] = 1; for(int i = timef - 1;i >= 0;i --){ f(j, 0, (1 << k) - 1){ int x = v[i]; if(h[x] < k){ dp[i][j] = dp[i + 1][j]; if(dp[i][j]) continue; } if((j >> h[x]) & 1) continue; dp[i][j] = dp[tout[x]][j | (1 << h[x])]; } } cout << (dp[1][0] ? "DA" : "NE"); }
#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...