# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156993 | 2019-10-08T21:30:33 Z | luciocf | Burza (COCI16_burza) | C++14 | 243 ms | 15908 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) continue; if (nivel[v] != k) dfs2(v, u); for (int mask = 0; mask < (1<<(k+1)); mask++) if (!(mask&(1<<nivel[v]))) dp[fim[v]][mask|(1<<nivel[v])] |= dp[ini[v]-1][mask]; } } 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+1)); mask++) dp[0][mask] = 1; dfs2(1, 0); bool ok = 0; for (int mask = 0; mask < (1<<(k+1)); mask++) ok |= dp[tt][mask]; if (ok) printf("DA\n"); else printf("NE\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 2808 KB | Output is correct |
2 | Correct | 243 ms | 15700 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 4 ms | 1784 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 227 ms | 13776 KB | Output is correct |
2 | Correct | 230 ms | 13688 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 230 ms | 13760 KB | Output is correct |
6 | Correct | 3 ms | 1912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 240 ms | 13904 KB | Output is correct |
2 | Correct | 226 ms | 13712 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 1400 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 5824 KB | Output is correct |
2 | Correct | 238 ms | 15908 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 1272 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 214 ms | 12072 KB | Output is correct |
2 | Correct | 228 ms | 13380 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 1784 KB | Output is correct |
6 | Correct | 4 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 230 ms | 14244 KB | Output is correct |
2 | Correct | 221 ms | 12920 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 4 ms | 1784 KB | Output is correct |
6 | Correct | 3 ms | 1148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 233 ms | 14256 KB | Output is correct |
2 | Correct | 221 ms | 13276 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 228 ms | 12920 KB | Output is correct |
6 | Correct | 3 ms | 1404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 4424 KB | Output is correct |
2 | Correct | 233 ms | 14968 KB | Output is correct |
3 | Correct | 3 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 1144 KB | Output is correct |
6 | Correct | 4 ms | 1784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 2172 KB | Output is correct |
2 | Correct | 235 ms | 15172 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 1144 KB | Output is correct |
6 | Correct | 3 ms | 1528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 5832 KB | Output is correct |
2 | Correct | 231 ms | 15204 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 233 ms | 6164 KB | Output is correct |
6 | Correct | 4 ms | 1016 KB | Output is correct |