# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885174 | PieArmy | Burza (COCI16_burza) | C++17 | 1 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
#define yem(re) (1ll<<(ll(re)))
#define endl '\n'
#define pb push_back
#define int long long
#define mid ((left+right)/2)
#define L(emanuelLasker,joseRaulCapablanca,anatolyKarpov) for(int emanuelLasker=(joseRaulCapablanca);emanuelLasker<=(anatolyKarpov);emanuelLasker++)
#define R(magnusCarlsen,paulMorphy,bobbyFischer) for(int magnusCarlsen=(paulMorphy);magnusCarlsen>=(bobbyFischer);magnusCarlsen--)
#define cint(vladimirKramnik) int vladimirKramnik;cin>>vladimirKramnik
#define inf (2e18+5)
#define sc second
#define fr first
#define Bismillahirrahmanirrahim ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cinarr(mikhailTal) for(auto &garryKasparov:mikhailTal)cin>>garryKasparov;
#define all(mustafaKemalAtaturk) mustafaKemalAtaturk.begin(),mustafaKemalAtaturk.end()
using namespace std;
mt19937 rng(chrono::high_resolution_clock().now().time_since_epoch().count());
void code(){
int n,k;cin>>n>>k;
vector<vector<int>>komsu(n,vector<int>(0));
L(i,1,n-1){
cint(x);cint(y);
x--;y--;
komsu[x].pb(y);
komsu[y].pb(x);
}
function<int(int,int,int)>f=[&](int pos,int root,int dep)->int{
if(dep==k)return 1;
multiset<int>st;
for(int x:komsu[pos]){
if(x==root)continue;
st.insert(-f(x,pos,dep+1));
}
if(st.size()==0)return 0;
int x=(*st.begin())+1;
st.erase(st.begin());
st.insert(x);
return max(0ll,-(*st.begin()));
};
int ans=f(0,0,0);
if(ans)cout<<"NE";
else cout<<"DA";
}
int32_t main(){
Bismillahirrahmanirrahim
int t=1;
bool usaco=0;
if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
if(!t)cin>>t;
while(t--){code();cout<<endl;}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |