# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010899 | 2024-06-29T13:59:54 Z | WhiteZeros | Burza (COCI16_burza) | C++17 | 11 ms | 860 KB |
#include <iostream> #include<bits/stdc++.h> using namespace std; #define task "coci1617_r2_burza" const int N = 4e2 + 1 , M = 20 , inf = 1e9 ; int n , k , stt = 0; vector<int> D[N] , depth[M] , cover[N]; int dp[1 << M] , tin[N] , tout[N] , pos[N]; void maximize(int &a , int b){ if(a < b) a = b ; } void minimize(int &a , int b){ if(a > b) a = b ; } void dfs(int u , int p , int h){ depth[h].push_back(u) ; if(h == k){ pos[u] = ++stt ; cover[u] = {u}; return ; } for(int v : D[u]){ if(v == p) continue; dfs(v , u , h + 1); cover[u].insert(cover[u].end() , cover[v].begin() , cover[v].end()) ; } } int main() { ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); if(ifstream(task".INP")){ freopen(task".INP","r",stdin) ; freopen(task".OUT","w",stdout) ; } cin >> n >> k ; if(k * k >= n){ cout <<"DA" ; return 0; } for(int i = 1 ; i <= n ; i++) tin[i] = inf ; for(int i = 1 ; i < n ; i++){ int u , v ; cin >> u >> v ; D[u].push_back(v) ; D[v].push_back(u) ; } dfs(1 , 0 , 0) ; for(int i = 1 ; i <= n ; i++){ if(cover[i].empty()) tin[i] = tout[i] = -1 ; else { tin[i] = pos[cover[i].front()] ; tout[i] = pos[cover[i].back()] ; } } dp[0] = 0 ; for(int i = 1 ; i < (1 << k) ; i++){ for(int j = 0 ; j < k ; j++) if(i >> j & 1) for(const int &v : D[j + 1]) { int pre = dp[i & ~(1 << j)] ; if(pre + 1>= tin[v]) maximize(dp[i] , tout[v]) ; } if(dp[i] == stt){ cout <<"DA\n" ; return 0 ; } } cout <<"NE\n" ; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 10 ms | 860 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 860 KB | Output is correct |
2 | Incorrect | 5 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 860 KB | Output is correct |
2 | Correct | 11 ms | 860 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Incorrect | 1 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 860 KB | Output is correct |
2 | Correct | 11 ms | 832 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 9 ms | 856 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |