# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
355379 | spatarel | Cat in a tree (BOI17_catinatree) | C++17 | 12 ms | 9324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <algorithm>
#include <vector>
const int MAX_N = 1500; // 200000
int N, D;
std::vector<int> children[MAX_N];
int maxN[MAX_N][1 + MAX_N];
int depth[MAX_N];
void dfs(int u) {
depth[u] = 1;
//int deepestChild = -1;
for (int v : children[u]) {
dfs(v);
if (depth[u] < 1 + depth[v]) {
depth[u] = 1 + depth[v];
//deepestChild = v;
}
}
maxN[u][0] = 1;
for (int v : children[u]) {
maxN[u][0] += maxN[v][D - 1];
}
std::vector<int> maxAdd(1 + D);
for (int v : children[u]) {
for (int d = 0; d < D && d < depth[v]; d++) {
maxN[u][d + 1] += maxN[v][d];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |