# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
915650 |
2024-01-24T13:03:57 Z |
0xZero |
Burza (COCI16_burza) |
C++17 |
|
0 ms |
0 KB |
#include "template_light.h"
#define bs bitset<mx>
const int mx=400;
int n, k;
vi adj[mx];
int dep[mx], mxd[mx]={0};
bool cmp (const bs & a, const bs & b){
F0R(i, 400)if(a[i]!=b[i])return a[i]<b[i];
return 0;
}
map<bs, bool, bool (*)(const bs &, const bs &)> dp(cmp);
void dfs(int u, int e){
mxd[u]=dep[u];
each(i, adj[u])if(i!=e){
dep[i]=dep[u]+1;
dfs(i, u);
mxd[u]=max(mxd[u], mxd[i]);
}
}
bool f(int x, int y, const bs &b){
if(x==y)return 0;
if(dp.count(b))return dp[b];
bs c(0);
bool ans=0;
F0R(i, n)if(b[i])each(j, adj[i])if(dep[j]>dep[i] && mxd[j]>=y)c[j]=1;
if(c.count()<=1)return 1;
F0R(i, n)if(c[i]){
c[i]=0;
ans|=f(x+1, y, c);
c[i]=1;
}
dp[b]=ans;
return ans;
}
int main(){
IOS;
re(n, k);
rep(n-1){
int a, b;
re(a, b);
a--;b--;
adj[a].pb(b);
adj[b].pb(a);
}
dep[0]=0;
dfs(0, -1);
bs b(1);
if(f(0, k, b))pr("DA");
else pr("NE");
return 0;
}
Compilation message
burza.cpp:1:10: fatal error: template_light.h: No such file or directory
1 | #include "template_light.h"
| ^~~~~~~~~~~~~~~~~~
compilation terminated.