Submission #406401

# Submission time Handle Problem Language Result Execution time Memory
406401 2021-05-17T14:33:09 Z NothingXD Burza (COCI16_burza) C++17
0 / 160
2 ms 480 KB
/*
You know, I've been around for a while now.
Not sure if I have much left to prove.
Yeah I do, haha!!
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define endl               '\n'
#define F                  first
#define S                  second
#define debug(x)           cerr << #x << " = " << x << endl
#define all(x)             x.begin(), x.end()
#define pb                 push_back
#define ppb                pop_back
#define MP                 make_pair

const int MAXN = 4e2 + 10;

int T, n, k;
vector<int> g[MAXN], Child[MAXN];
vector<pair<int,int>> GChild[MAXN];
bool visited[MAXN], dp[MAXN][MAXN];

void MT(int v){
    GChild[v].pb({0, 0});
    visited[v] = true;
    for (auto u: g[v]){
        if (!visited[u]){
            MT(u);
            Child[v].pb(u);
            for (auto w: Child[u]){
                GChild[v].pb({w, u});
            }
        }
    }
}

void DFS(int v, int k){
    if (!k) return;
    for (auto u: Child[v]){
        DFS(u, k-1);
    }
    for (auto i: Child[v]){
        for (auto [j, k]: GChild[v]){
            bool res = true;
            for (auto u: Child[v]){
                if (u == i) continue;
                if (u == k) res = (res && dp[u][j]);
                else res = (res && dp[u][0]);
            }
            dp[v][i] = (dp[v][i] || res);
        }
    }
    for (auto [j, k]: GChild[v]){
        bool res = true;
        for (auto u: Child[v]){
            if (u == k) res = (res && dp[u][j]);
            else res = (res && dp[u][0]);
        }
        dp[v][0] = (dp[v][0] || res);
    }
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
    
    T = 1;
//    cin >> T;
    while(T--){
        cin >> n >> k;
        for (int i = 1; i < n; i++){
            int u, v; cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }
        MT(1);
        DFS(1, k);
        bool res = false;
        for (auto u: Child[1]){
            res = (res || dp[1][u]);
        }
        res = (res || dp[1][0]);
        cout << (res?"DA":"NE");
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -