# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
783054 |
2023-07-14T14:34:49 Z |
Ahmed57 |
Burza (COCI16_burza) |
C++17 |
|
127 ms |
53868 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();
}
bool dp[401][(1<<20)];int n,k;
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);
for(int i = n;i>=1;i--){
for(int mask = 0;mask<(1<<k);mask++){
if(i==n){
dp[i][mask] = 1;
continue;
}
dp[i][mask] = 0;
if(!(mask&(1<<lol[eu[i]]))){
dp[i][mask]|=dp[en[eu[i]]][mask|(1<<lol[eu[i]])];
}
if(lol[eu[i]]+1<k){
dp[i][mask]|=dp[i+1][mask];
}
}
}
cout<<(dp[1][0]?"DA":"NE")<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
7124 KB |
Output is correct |
2 |
Correct |
100 ms |
53868 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
51232 KB |
Output is correct |
2 |
Correct |
95 ms |
51504 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
101 ms |
52100 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
127 ms |
51820 KB |
Output is correct |
2 |
Correct |
96 ms |
51912 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
2132 KB |
Output is correct |
6 |
Correct |
1 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
14524 KB |
Output is correct |
2 |
Correct |
96 ms |
53868 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
49536 KB |
Output is correct |
2 |
Correct |
94 ms |
51236 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
2632 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
51636 KB |
Output is correct |
2 |
Correct |
94 ms |
50768 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
2388 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
52492 KB |
Output is correct |
2 |
Correct |
92 ms |
51096 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
91 ms |
51216 KB |
Output is correct |
6 |
Correct |
2 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
13020 KB |
Output is correct |
2 |
Correct |
94 ms |
52788 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
6484 KB |
Output is correct |
2 |
Correct |
97 ms |
53300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1748 KB |
Output is correct |
6 |
Correct |
2 ms |
2388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
23560 KB |
Output is correct |
2 |
Correct |
99 ms |
53200 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
42 ms |
23812 KB |
Output is correct |
6 |
Correct |
1 ms |
1360 KB |
Output is correct |