# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550301 | aryan12 | Cat in a tree (BOI17_catinatree) | C++17 | 1084 ms | 22060 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;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5;
vector<int> g[N];
int n, d;
deque<int> dfs(int node, int par)
{
deque<int> cur_ans;
cur_ans.push_back(1); // this node
for(int to: g[node])
{
if(to == par)
{
continue;
}
deque<int> child_ans = dfs(to, node);
child_ans.push_front(child_ans[0]); // maintaining depths
if(child_ans.size() > cur_ans.size())
{
swap(child_ans, cur_ans);
}
for(int i = 0; i < child_ans.size(); i++)
{
int pos = d - i;
int max_val = child_ans[i] + ((pos < cur_ans.size()) ? (cur_ans[max(i, pos)]) : (0LL));
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... |