Submission #98527

# Submission time Handle Problem Language Result Execution time Memory
98527 2019-02-23T20:41:25 Z dalgerok Burza (COCI16_burza) C++17
0 / 160
31 ms 644 KB
#include<bits/stdc++.h>
using namespace std;


const int M = 405, N = 20;




int n, k, d[M];
int tin[M], tout[M], timer;
vector < int > g[M], q[M];
bitset < (1 << N) > dp[M];

void dfs(int v, int pr = -1){
    if(d[v] == k){
        timer += 1;
        tin[v] = timer;
        tout[v] = timer;
        return;
    }
    tin[v] = timer;
    for(int to : g[v]){
        if(to != pr){
            d[to] = d[v] + 1;
            dfs(to, v);
        }
    }
    tout[v] = timer;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    if(k * k >= n){
        return cout << "DA", 0;
    }
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        x -= 1;
        y -= 1;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0);
    for(int i = 0; i < n; i++){
        q[tin[i]].push_back(i);
    }
    dp[1][0] = true;
    for(int i = 1; i <= timer; i++){
        for(int j = 0; j < (1 << k); j++){
            if(dp[i][j] == true){
                for(auto it : q[i]){
                    if(!((j >> d[it]) & 1)){
                        dp[tout[it] + 1][j | (1 << d[it])] = true;
                    }
                }
            }
        }
    }
    for(int i = 0; i < (1 << k); i++){
        if(dp[timer + 1][i] == true){
            return cout << "DA", 0;
        }
    }
    cout << "NE";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 31 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 15 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 384 KB Output is correct
2 Correct 15 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 3 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 512 KB Output is correct
2 Correct 19 ms 496 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 18 ms 496 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 3 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 17 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 3 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 384 KB Output is correct
2 Correct 16 ms 644 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 14 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 18 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 512 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 30 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 11 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -