# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
783044 |
2023-07-14T14:29:50 Z |
Ahmed57 |
Burza (COCI16_burza) |
C++17 |
|
101 ms |
1360 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&1][mask] = 0;
continue;
}
if(!(mask&(1<<lol[eu[i]]))){
dp[i&1][mask]|=dp[en[eu[i]]][mask|(1<<lol[eu[i]])];
}
if(lol[eu[i]]+1<k){
dp[i&1][mask]|=dp[i+1][mask];
}
}
}
cout<<(dp[1][0]?"DA":"NE")<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
980 KB |
Output is correct |
2 |
Correct |
91 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
356 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1104 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
1292 KB |
Output is correct |
2 |
Correct |
86 ms |
1320 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
93 ms |
1280 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
1332 KB |
Output is correct |
2 |
Correct |
83 ms |
1352 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1108 KB |
Output is correct |
2 |
Correct |
86 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
1244 KB |
Output is correct |
2 |
Correct |
86 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
1356 KB |
Output is correct |
2 |
Correct |
86 ms |
1356 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
1284 KB |
Output is correct |
2 |
Correct |
82 ms |
1284 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
83 ms |
1240 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1072 KB |
Output is correct |
2 |
Correct |
84 ms |
1352 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
944 KB |
Output is correct |
2 |
Correct |
101 ms |
1344 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1092 KB |
Output is correct |
2 |
Correct |
85 ms |
1360 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
37 ms |
1028 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |