답안 #783052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783052 2023-07-14T14:32:14 Z Ahmed57 Burza (COCI16_burza) C++17
0 / 160
107 ms 47872 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<<20)];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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 6356 KB Output is correct
2 Correct 95 ms 47872 KB Output is correct
3 Runtime error 8 ms 2608 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 46068 KB Output is correct
2 Correct 96 ms 46420 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 46836 KB Output is correct
2 Correct 93 ms 46752 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 12620 KB Output is correct
2 Correct 96 ms 47764 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 45268 KB Output is correct
2 Correct 104 ms 46304 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 46188 KB Output is correct
2 Correct 98 ms 46064 KB Output is correct
3 Runtime error 8 ms 2600 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 47272 KB Output is correct
2 Correct 94 ms 46080 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 11616 KB Output is correct
2 Correct 94 ms 47200 KB Output is correct
3 Runtime error 8 ms 2608 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 5896 KB Output is correct
2 Correct 95 ms 47700 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 21520 KB Output is correct
2 Correct 107 ms 47436 KB Output is correct
3 Runtime error 8 ms 2516 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -