# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156992 | 2019-10-08T21:09:33 Z | luciocf | Burza (COCI16_burza) | C++14 | 86 ms | 632 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 410; int n, k; int nivel[maxn]; int ini[maxn], fim[maxn], tt; bool dp[maxn][1<<20]; vector<int> grafo[maxn]; void dfs(int u, int p) { if (nivel[u] == k) { ini[u] = ++tt; fim[u] = tt; return; } ini[u] = n+1; for (auto v: grafo[u]) { if (v == p) continue; nivel[v] = nivel[u]+1; dfs(v, u); ini[u] = min(ini[u], ini[v]); fim[u] = max(fim[u], fim[v]); } } void dfs2(int u, int p) { for (auto v: grafo[u]) { if (v == p || nivel[v] == k) continue; for (int mask = 0; mask < (1<<k); mask++) if (!(mask&(1<<nivel[v]))) dp[fim[v]][mask&(1<<nivel[v])] |= dp[ini[v]-1][mask]; dfs2(v, u); } } int main(void) { scanf("%d %d", &n, &k); for (int i = 1; i < n; i++) { int u, v; scanf("%d %d", &u, &v); grafo[u].push_back(v); grafo[v].push_back(u); } if (k >= 20) { printf("DA\n"); return 0; } dfs(1, 0); if (tt == 0) { printf("DA\n"); return 0; } for (int mask = 0; mask < (1<<k); mask++) dp[0][mask] = 1; dfs2(1, 0); bool ok = 0; for (int mask = 0; mask < (1<<k); mask++) ok |= dp[tt][mask]; if (ok) printf("DA\n"); else printf("NE\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 80 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 82 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 568 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 86 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 83 ms | 632 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 86 ms | 616 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 476 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |