답안 #885174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
885174 2023-12-09T07:23:24 Z PieArmy Burza (COCI16_burza) C++17
0 / 160
1 ms 600 KB
#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

burza.cpp: In function 'int32_t main()':
burza.cpp:52:22: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |               ~~~~~~~^~~~~~~~~~~~~~~~~
burza.cpp:52:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -