Submission #783053

# Submission time Handle Problem Language Result Execution time Memory
783053 2023-07-14T14:33:05 Z Ahmed57 Burza (COCI16_burza) C++17
0 / 160
127 ms 48716 KB
#include<bits/stdc++.h>

using namespace std;
vector<int> eu;int en[401],lol[401];
vector<int> adj[401];
void dfs(int i,int pr,int dep){
    eu.push_back(i);
    lol[i] = dep;
    for(auto j:adj[i]){
        if(j==pr)continue;
        dfs(j,i,dep+1);
    }
    en[i] = eu.size();
}
bool dp[401][(1<<21)];int n,k;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    if(n<=k*(k+1)/2){
        cout<<"DA\n";
        return 0;
    }
    for(int i = 0;i<n-1;i++){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1,0,-1);
    for(int i = n;i>=1;i--){
        for(int mask = 0;mask<(1<<k);mask++){
            if(i==n){
                dp[i][mask] = 0;
                continue;
            }
            if(!(mask&(1<<lol[eu[i]]))){
                dp[i][mask]|=dp[en[eu[i]]][mask|(1<<lol[eu[i]])];
            }
            if(lol[eu[i]]+1<k){
                dp[i][mask]|=dp[i+1][mask];
            }
        }
    }
    cout<<(dp[1][0]?"DA":"NE")<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 6996 KB Output is correct
2 Correct 99 ms 48716 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 46748 KB Output is correct
2 Correct 94 ms 47180 KB Output is correct
3 Runtime error 14 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 47484 KB Output is correct
2 Correct 93 ms 47564 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 13320 KB Output is correct
2 Correct 127 ms 48508 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 89 ms 46008 KB Output is correct
2 Correct 110 ms 47144 KB Output is correct
3 Runtime error 14 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 46924 KB Output is correct
2 Correct 92 ms 46824 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 48084 KB Output is correct
2 Correct 106 ms 46836 KB Output is correct
3 Runtime error 15 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 12276 KB Output is correct
2 Correct 108 ms 48016 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 6484 KB Output is correct
2 Correct 98 ms 48456 KB Output is correct
3 Runtime error 14 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 22292 KB Output is correct
2 Correct 98 ms 48204 KB Output is correct
3 Runtime error 13 ms 2388 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -