# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
783034 |
2023-07-14T14:25:29 Z |
Ahmed57 |
Burza (COCI16_burza) |
C++17 |
|
259 ms |
524288 KB |
#include<bits/stdc++.h>
using namespace std;
vector<int> eu;int en[401],lol[401];
vector<int> adj[401];
void dfs(int i,int pr,int dep){
eu.push_back(i);
lol[i] = dep;
for(auto j:adj[i]){
if(j==pr)continue;
dfs(j,i,dep+1);
}
en[i] = eu.size();
}
int dp[401][(1<<20)];int n,k;
int solve(int i,int mask){
if(i==n){
return 1;
}
if(dp[i][mask]!=-1)return dp[i][mask];
int c1 = 0;
if(!(mask&(1<<lol[eu[i]]))){
c1|=solve(en[eu[i]],mask|(1<<lol[eu[i]]));
}
if(lol[eu[i]]+1<k){
c1|=solve(i+1,mask);
}
return dp[i][mask] = c1;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>k;
if(n<=k*k){
cout<<"DA\n";
return 0;
}
for(int i = 0;i<n-1;i++){
int a,b;cin>>a>>b;
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs(1,0,-1);
memset(dp,-1,sizeof dp);
cout<<(solve(1,0)?"DA":"NE")<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
259 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
171 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
192 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
177 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
228 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
169 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
173 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
169 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
173 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
174 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |