# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422868 | valerikk | Arboras (RMI20_arboras) | C++17 | 537 ms | 14136 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
const int N = 1e5 + 7;
const int md = 1e9 + 7;
int n, q;
int p[N], d[N];
vector<int> g[N];
int best[N], best2[N];
int dp[N], dp2[N];
int sum = 0;
void dfs(int v) {
best[v] = best2[v] = -1;
dp[v] = dp2[v] = 0;
for (int u : g[v]) {
dfs(u);
if (dp[u] + d[u] > dp[v]) {
dp2[v] = dp[v], best2[v] = best[v];
dp[v] = dp[u] + d[u], best[v] = u;
} else if (dp[u] + d[u] > dp2[v]) {
dp2[v] = dp[u] + d[u];
best2[v] = u;
}
}
sum += dp[v] + dp2[v];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |