Submission #133807

# Submission time Handle Problem Language Result Execution time Memory
133807 2019-07-21T12:47:29 Z forelax Burza (COCI16_burza) C++14
0 / 160
3 ms 632 KB
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > ng;
vector<int> dp;
int n,k;
void build(int ind,int par,int dep){
    if(dep==k-1){
        if(ng[ind].size()-(par!=-1?1:0)>=2)
            dp[ind]=1e6;
        else if(ng[ind].size()-(par!=-1?1:0)==1)
            dp[ind]=1;
        else
            dp[ind]=0;
        return;
    }
    if(dep!=0&&ng[ind].size()==1){
        dp[ind]=0;
        return;
    }
    int sm=0;
    int mx=0;
    for(int i = 0 ; i < ng[ind].size() ; i ++){
        int ne=ng[ind][i];
        if(ne==par)continue;
        build(ne,ind,dep+1);
        sm+=dp[ne];
        mx=max(dp[ne],mx);
    }
    dp[ind]=sm-mx+min(mx,1);
}
int main(){
    cin>>n>>k;
    ng.resize(n);
    dp.resize(n);
    for(int i = 0,a,b ; i < n-1 ; i ++){
        cin>>a>>b;a--;b--;
        ng[a].push_back(b);
        ng[b].push_back(a);
    }
    build(0,-1,0);
//    for(int i = 0 ; i < n ; i ++)
//        cout<<i<<" "<<dp[i]<<endl;;
    if(dp[0]<=k){
        cout<<"DA";
    }else{
        cout<<"NE";
    }
}

Compilation message

burza.cpp: In function 'void build(int, int, int)':
burza.cpp:22:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < ng[ind].size() ; i ++){
                     ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -