# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936536 |
2024-03-02T06:23:33 Z |
parsadox2 |
Burza (COCI16_burza) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 4e2 + 10 , Lg = 10;
int n , k , dp[N][(1 << Lg)] , dis[N];
vector <int> adj[N];
void Dfs(int v , int p = 0)
{
for(auto u : adj[v]) if(u != p)
{
dis[u] = dis[v] + 1;
Dfs(u , v);
}
//cout << v << " " << dis[v] << ":: " << endl;
for(int mask = 0 ; mask < (1 << k) ; mask++)
{
bool flg = false;
for(int i = 0 ; i <= min(k - 1 , dis[v]) ; i++) if((mask >> i) & 1)
flg = true;
if(flg)
dp[v][mask] = -N;
else
dp[v][mask] = dis[v];
}
for(auto u : adj[v]) if(u != p)
{
for(int mask = (1 << k) - 1 ; mask > -1 ; mask--)
{
if(dp[v][mask] == -N)
break;
dp[v][mask] = max(dp[v][mask] , dp[u][0]);
for(int s = mask ; s > 0 ; s = ((s - 1) & mask))
dp[v][mask] = min(dp[v][mask] , max(dp[v][mask - s] , dp[u][s]));
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for(int i = 0 ; i < n - 1 ; i++)
{
int u , v; cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
assert(k >= Lg);
if(k >= Lg)
{
cout << "DA" << '\n';
return 0;
}
dis[1] = -1;
Dfs(1);
cout << (dp[1][(1 << k) - 1] < k - 1 ? "DA" : "NE") << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |