답안 #1010096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010096 2024-06-28T10:22:51 Z vjudge1 Burza (COCI16_burza) C++17
160 / 160
18 ms 1204 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[401];
vector<pair<int,int>>go[401];
int in[401],out[401],par[401],dep[401],ok[401],C,k;
bitset<1<<19>dp[401];
void dfs(int n){
    for(auto i:adj[n]) if(i-par[n])
        par[i]=n,dep[i]=dep[n]+1,dfs(i);
}
void dfs2(int n){
    in[n]=C;
    if(dep[n]==k){
        out[n]=++C;
        return;
    }
    for(auto i:adj[n])
        if(i-par[n]&&ok[i])
            dfs2(i);
    out[n]=C;
}
int main(){
    int n;
    cin>>n>>k;
    if(k>19)return puts("DA"),0;
    for(int i=1;i<n;i++){
        int a,b; cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1);
    for(int i=1,j;i<=n;i++)
        if(dep[j=i]==k)
            do ok[j]=1;
            while(j=par[j]);
    dfs2(1);
    for(int i=2;i<=n;i++)if(ok[i])
        go[in[i]].push_back({out[i],dep[i]-1});
    dp[0][0]=1;
    for(int i=0;i<C;i++) for(int j=0;j<1<<k;j++)
        if(dp[i][j]) for(auto[m,d]:go[i])
            if(~j&1<<d) dp[m][j|1<<d]=1;
    puts(dp[C].count()?"DA":"NE");
}

Compilation message

burza.cpp: In function 'int main()':
burza.cpp:35:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   35 |             while(j=par[j]);
      |                   ~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 14 ms 904 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1204 KB Output is correct
2 Correct 10 ms 860 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 13 ms 860 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 860 KB Output is correct
2 Correct 12 ms 716 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 16 ms 872 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 856 KB Output is correct
2 Correct 14 ms 860 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 860 KB Output is correct
2 Correct 17 ms 860 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 856 KB Output is correct
2 Correct 13 ms 860 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 12 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 13 ms 804 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 18 ms 860 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 600 KB Output is correct
2 Correct 18 ms 812 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 7 ms 648 KB Output is correct
6 Correct 1 ms 604 KB Output is correct