# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
134259 | Kastanda | Cat in a tree (BOI17_catinatree) | C++11 | 153 ms | 25456 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>
using namespace std;
const int N = 200005;
int n, d;
vector < int > D[N], Adj[N];
inline int Get(int v, int i)
{
i = (int)D[v].size() - 1 - max(i, 0);
if (i < 0)
return 0;
return (D[v][i]);
}
void DFS(int v)
{
for (int &u : Adj[v])
{
DFS(u);
if (D[v].size() < D[u].size())
D[v].swap(D[u]);
vector < int > vec(D[u].size(), 0);
for (int i = 0; i < D[u].size(); i++)
{
vec[i] = max(vec[i], Get(u, i) + Get(v, max(d - i - 2, i)));
vec[i] = max(vec[i], Get(v, i) + Get(u, max(d - i - 2, i)));
}
for (int i = (int)D[u].size() - 1; ~ i; i --)
{
int id = (int)D[v].size() - 1 - i;
D[v][id] = max(D[v][id], vec[i]);
if (id) D[v][id] = max(D[v][id], D[v][id - 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... |