Submission #1109921

# Submission time Handle Problem Language Result Execution time Memory
1109921 2024-11-08T06:01:21 Z 12345678 Burza (COCI16_burza) C++17
0 / 160
1 ms 336 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=405;

int n, k, u, v, dp[10005], lvl[nx], c[nx], t, l[nx], r[nx];
vector<int> d[nx], dpt[nx];

void dfs(int u, int p)
{
    lvl[u]=lvl[p]+1;
    l[u]=n;
    if (lvl[u]==k-1) return l[u]=r[u]=++t, c[u]=1, dpt[k-1].push_back(u), void();
    for (auto v:d[u]) if (v!=p) dfs(v, u), c[u]=c[u]||c[v], l[u]=min(l[u], l[v]), r[u]=r[v];
    if (c[u]&&u!=1) dpt[lvl[u]].push_back(u);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>k;
    for (int i=1; i<n; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
    if (n<(1<<(k+1))-1) return cout<<"DA", 0;
    lvl[1]=-2;
    dfs(1, 1);
    //for (int i=1; i<=n; i++) cout<<"l "<<l[i]<<' '<<r[i]<<'\n';
    for (int msk=1; msk<(1<<k); msk++)
    {
        for (int i=0; i<k; i++) if (msk&(1<<i)) for (auto u:dpt[i]) if (dp[msk^(1<<i)]+1>=l[u]) dp[msk]=max({dp[msk^(1<<i)], dp[msk], r[u]});
        //cout<<"debug "<<msk<<' '<<dp[msk]<<'\n';
    }
    if (dp[(1<<k)-1]==t) cout<<"DA";
    else cout<<"NE";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -