# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1010901 | 2024-06-29T14:03:21 Z | WhiteZeros | Burza (COCI16_burza) | C++17 | 35 ms | 1020 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){ tin[u] = tout[u] = ++stt ; return ; } for(int v : D[u]){ if(v == p) continue; dfs(v , u , h + 1); minimize(tin[u] , tin[v]) ; maximize(tout[u] , tout[v]) ; } } 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) ; dp[0] = 0 ; for (int ss = 1; ss < (1 << k); ss++) { int &curr = dp[ss]; for (int to_add = 0; to_add < k; to_add++) { if ((ss & (1 << to_add)) != 0) { int prev = dp[ss & ~(1 << to_add)]; for (int n : depth[to_add + 1]) { if (tin[n] <= prev + 1) { curr = max(curr, tout[n]); } } } } if (dp[ss] == stt) { cout << "DA" << endl; return 0; } } cout << "NE" << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 26 ms | 976 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 848 KB | Output is correct |
2 | Correct | 26 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 | Correct | 25 ms | 996 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 976 KB | Output is correct |
2 | Correct | 25 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 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 604 KB | Output is correct |
2 | Correct | 35 ms | 848 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 860 KB | Output is correct |
2 | Correct | 27 ms | 860 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 476 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 856 KB | Output is correct |
2 | Correct | 25 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 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 860 KB | Output is correct |
2 | Correct | 32 ms | 840 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 26 ms | 860 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 600 KB | Output is correct |
2 | Correct | 25 ms | 1020 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 27 ms | 956 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 720 KB | Output is correct |
2 | Correct | 26 ms | 856 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 12 ms | 720 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |