# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936538 |
2024-03-02T06:25:34 Z |
parsadox2 |
Burza (COCI16_burza) |
C++14 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 405;
vector<int> adj[N];
int par[N], dep[N], t;
array<int, 2> v[N];
int n, k;
vector<int> gud[N];
void dfs(int i, int p, int d) {
for (auto nxt : adj[i]) {
if (nxt == p) continue;
dfs(nxt, i, d + 1);
v[i][0] = min(v[i][0], v[nxt][0]);
v[i][1] = max(v[i][1], v[nxt][1]);
}
dep[i] = d;
if (d == k) {
v[i][0] = min(v[i][0], t);
v[i][1] = max(v[i][1], t);
t++;
}
if (v[i][0] != n + 1) {
par[i] = p;
gud[d].push_back(i);
}
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
if (k >= 12) {
cout << "DA\n";
return 0;
}
for (int i = 1, u, v; i < n; i++) {
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 1; i <= n; i++) {
v[i] = {n + 1, -1};
}
dfs(1, 0, 0);
for (int i = 1; i <= n; i++) adj[i].clear();
for (int i = 1; i <= n; i++) {
if (!par[i]) continue;
adj[par[i]].push_back(i);
}
// for (int i = 1; i <= k; i++) {
// for (auto j : gud[i]) {
// cout << v[j][0] << ", " << v[j][1] << '\n';
// }
// cout << '\n';
// }
int m = 1 << k, dp[m];
dp[0] = -1;
for (int msk = 1; msk < m; msk++) {
dp[msk] = -1;
for (int j = 1; j <= k; j++) {
if (!((msk >> (j - 1)) & 1)) continue;
for (auto i : gud[j]) {
if (v[i][0] <= dp[msk ^ (1 << (j - 1))] + 1) {
dp[msk] = max(dp[msk], v[i][1]);
}
}
}
}
if (dp[m - 1] == t - 1) {
cout << "DA\n";
} else {
cout << "NE\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
- |
# |
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 |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |