# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
783049 |
2023-07-14T14:30:59 Z |
Ahmed57 |
Burza (COCI16_burza) |
C++17 |
|
115 ms |
47864 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] = 0;
continue;
}
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 |
11 ms |
6356 KB |
Output is correct |
2 |
Correct |
96 ms |
47864 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
46032 KB |
Output is correct |
2 |
Correct |
100 ms |
46528 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
94 ms |
47108 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
46772 KB |
Output is correct |
2 |
Correct |
92 ms |
46740 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2132 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
12584 KB |
Output is correct |
2 |
Correct |
101 ms |
47672 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
1876 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
45184 KB |
Output is correct |
2 |
Correct |
98 ms |
46396 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
46152 KB |
Output is correct |
2 |
Correct |
94 ms |
46060 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
2388 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
47248 KB |
Output is correct |
2 |
Correct |
94 ms |
46176 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
90 ms |
46604 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
11628 KB |
Output is correct |
2 |
Correct |
115 ms |
47176 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
1748 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
5892 KB |
Output is correct |
2 |
Correct |
94 ms |
47624 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
1748 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
21580 KB |
Output is correct |
2 |
Correct |
98 ms |
47436 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Incorrect |
42 ms |
21748 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |