Submission #885559

#TimeUsernameProblemLanguageResultExecution timeMemory
885559parlimoosBurza (COCI16_burza)C++14
0 / 160
1 ms604 KiB
//Be Name KHODA #pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pp pop_back #define lb lower_bound #define ub upper_bound #define cl clear #define bg begin #define arr(x) array<int , x> #define endl '\n' int n , k; vector<int> tr[400]; bool dp[400][400]; int hs[400]; void init(){ fill(&hs[0] , &hs[n] , -1); queue<int> q; q.push(0); hs[0] = 0; while(!q.empty()){ int v = q.front(); q.pop(); for(int u : tr[v]){ if(hs[u] == -1){ hs[u] = hs[v] + 1; q.push(u); } } } } void f(int v = 0 , int p = -1){ if(hs[v] >= k){ dp[v][k] = 1; }else{ for(int u : tr[v]){ if(u != p){ f(u , v); for(int i = 399 ; i >= 0 ; i--){ if(!dp[u][i]) continue; for(int j = i ; j >= hs[v] ; j--){ if(!dp[v][j]){ dp[v][j] = 1; break; } } } if(dp[v][hs[v]]) for(int i = hs[v] + 1 ; i < 400 ; i++) dp[v][i] = 0; } } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i = 1 ; i < n ; i++){ int v , u; cin >> v >> u; v-- , u--; tr[v].pb(u) , tr[u].pb(v); } init(); f(); // for(int i = 0 ; i < n ; i++){ // cout << i << " : "; // for(int j = 0 ; j < 10 ; j++) cout << dp[i][j] << " "; // cout << endl; // } if(dp[0][0]) cout << "NE"; else cout << "DA"; }
#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...