#include<bits/stdc++.h>
using namespace std;
const int N = 20;
int n, k, d[N * N];
int tin[N * N], tout[N * N], timer;
vector < int > g[N * N] q[N * N];
bitset < (1 << N) > dp[N + 1];
void dfs(int v, int pr = -1){
if(d[v] == k){
tin[v] = tout[v] = timer++;
return;
}
tin[v] = timer;
for(int to : g[v]){
if(to != pr){
d[to] = d[v] + 1;
dfs(to, v);
}
}
tout[v] = timer;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
if(k * k >= n){
return cout << "DA", 0;
}
for(int i = 1; i < n; i++){
int x, y;
cin >> x >> y;
x -= 1;
y -= 1;
g[x].push_back(y);
g[y].push_back(x);
}
dfs(0);
for(int i = 0; i < n; i++){
q[tin[i]].push_back(i);
}
dp[0][0] = true;
for(int i = 0; i < timer; i++){
for(int j = 0; j < (1 << k); j++){
if(dp[i][j] == true){
for(auto it : q[i]){
if(!((j >> d[it]) & 1)){
dp[tout[it] + 1][j ^ (1 << d[it])] = true;
}
}
}
}
}
for(int i = 0; i < (1 << k); i++){
if(dp[timer][i] == true){
return cout << "DA", 0;
}
}
cout << "NE";
}
Compilation message
burza.cpp:12:25: error: expected initializer before 'q'
vector < int > g[N * N] q[N * N];
^
burza.cpp: In function 'void dfs(int, int)':
burza.cpp:21:18: error: 'g' was not declared in this scope
for(int to : g[v]){
^
burza.cpp: In function 'int main()':
burza.cpp:41:9: error: 'g' was not declared in this scope
g[x].push_back(y);
^
burza.cpp:46:9: error: 'q' was not declared in this scope
q[tin[i]].push_back(i);
^
burza.cpp:52:31: error: 'q' was not declared in this scope
for(auto it : q[i]){
^