# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1109925 |
2024-11-08T06:07:52 Z |
12345678 |
Burza (COCI16_burza) |
C++17 |
|
36 ms |
980 KB |
#include <bits/stdc++.h>
using namespace std;
const int nx=405;
int n, k, u, v, dp[(1<<20)], lvl[nx], c[nx], t, l[nx], r[nx];
vector<int> d[nx], dpt[nx];
void dfs(int u, int p)
{
lvl[u]=lvl[p]+1;
l[u]=INT_MAX;
if (lvl[u]==k-1) return l[u]=r[u]=++t, dpt[lvl[u]].push_back(u), void();
for (auto v:d[u]) if (v!=p) dfs(v, u), l[u]=min(l[u], l[v]), r[u]=max(r[u], r[v]);
if (u!=1) dpt[lvl[u]].push_back(u);
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>k;
for (int i=1; i<n; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
if (n<k*k) return cout<<"DA", 0;
lvl[1]=-2;
dfs(1, 1);
for (int msk=1; msk<(1<<k); msk++)
{
for (int i=0; i<k; i++) if (msk&(1<<i)) for (auto u:dpt[i]) if (dp[msk^(1<<i)]+1>=l[u]) dp[msk]=max({dp[msk], r[u]});
//cout<<"debug "<<msk<<' '<<dp[msk]<<'\n';
if (dp[msk]==t) return cout<<"DA", 0;
}
cout<<"NE";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
336 KB |
Output is correct |
2 |
Correct |
36 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
896 KB |
Output is correct |
2 |
Correct |
33 ms |
884 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
33 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
848 KB |
Output is correct |
2 |
Correct |
33 ms |
960 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
592 KB |
Output is correct |
2 |
Correct |
36 ms |
800 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
848 KB |
Output is correct |
2 |
Correct |
32 ms |
972 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
840 KB |
Output is correct |
2 |
Correct |
34 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
848 KB |
Output is correct |
2 |
Correct |
33 ms |
824 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
34 ms |
848 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
760 KB |
Output is correct |
2 |
Correct |
34 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
336 KB |
Output is correct |
2 |
Correct |
36 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
724 KB |
Output is correct |
2 |
Correct |
36 ms |
848 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
19 ms |
592 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |