# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164591 | dolphingarlic | Cat in a tree (BOI17_catinatree) | C++14 | 184 ms | 18040 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 <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int n, d;
vector<int> graph[200001];
// dp: Maximum number of marked nodes in subtree of i
// to_root: Minimum length of path from a marked node to the root
// mn_dist: Maximum length of path from a marked node to the root after
// the erasing of another marked node
int dp[200001], to_root[200001], mn_dist[200001];
void dfs(int node = 0) {
if (graph[node].size()) {
int v = graph[node][0];
dfs(v);
if (to_root[v] + 1 >= d) {
// We mark the root
dp[node] = dp[v] + 1;
to_root[node] = 0;
mn_dist[node] = to_root[v] + 1;
} else {
// We don't
dp[node] = dp[v];
to_root[node] = to_root[v] + 1;
mn_dist[node] = mn_dist[v] + 1;
}
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... |