Submission #133813

# Submission time Handle Problem Language Result Execution time Memory
133813 2019-07-21T13:09:15 Z forelax Burza (COCI16_burza) C++14
0 / 160
3 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > ng;
vector<int> dp;
vector<bool> md;
int n,k;
void build(int ind,int par,int dep){
    if(dep==k){
        dp[ind]=1e6;
        md[ind]=true;
        return;
    }
    int mx=0;
    int sm=0;
    for(int i = 0 ; i < ng[ind].size() ; i ++){
        int ne=ng[ind][i];
        if(ne==par)continue;
        build(ne,ind,dep+1);
        if(md[ne]){
            md[ind]=true;
            sm+=dp[ind];
            mx=max(dp[ind],mx);
        }
    }
    dp[ind]=sm-mx+min(mx,1);
}
int main(){
    cin>>n>>k;
    ng.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);
    }
    dp.resize(n);
    md.resize(n);
    build(0,-1,0);
//    for(int i = 0 ; i < n ; i ++)
//        cout<<i<<" "<<dp[i]<<endl;;
//    cout<<"NE";
//    return 0;
    if(dp[0]<=k){
        cout<<"DA";
    }else{
        cout<<"NE";
    }
}

Compilation message

burza.cpp: In function 'void build(int, int, int)':
burza.cpp:15: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 2 ms 348 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 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 256 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 -