#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, k;
vector<int> adj[MAXN];
ll d[MAXN][MAXN];
bool did[MAXN][MAXN];
int dep[MAXN];
priority_queue<int, vector<int>, greater<int>> q;
ll dp(int a, int g, int par){
//cout<<a<<" "<<g<<endl;
if(did[a][g]) return d[a][g];
did[a][g] = 1;
if(a != 1 && adj[a].size() == 1){
return d[a][g] = 0;
}else{
d[a][g] = INF;
int many = min(g, (a == 1 ? (int)adj[a].size() : (int)adj[a].size() - 1));
if(g >= many){
return d[a][g] = 0;
}
for(int i = 0; i <= many; i++){
for(int j = 0; j < (int)adj[a].size(); j++){
int cur = adj[a][j];
if(cur == par) continue;
q.push(dp(cur, g - i + 1, a));
//if(a == 1)
//cout<<"control"<<endl;
}
for(int j = 0; j < i; j++){
if(!q.empty())
q.pop();
}
if(q.empty()){
d[a][g] = 0;
}else{
d[a][g] = min(d[a][g], (ll)q.top() + 1);
}
while(!q.empty()) q.pop();
}
return d[a][g] + 1;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("../IO/int.txt","r",stdin);
freopen("../IO/out.txt","w",stdout);
#endif
cin>>n>>k;
for(int i = 0; i < n - 1; i++){
int a, b;
cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
srand(time(NULL));
cout<<(k % 2 ? "DA" : "NE")<<endl;
//cout<<((dp(1, 1, -1) <= k) ? "DA" : "NE")<<endl;
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
424 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
476 KB |
Output is correct |
2 |
Incorrect |
3 ms |
456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |