# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
400406 | Haunted_Cpp | Factories (JOI14_factories) | C++17 | 5440 ms | 333836 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 "factories.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX_N = 500000 + 5;
const i64 INF = 1e18;
vector<pair<int, int>> g[MAX_N];
vector<pair<int, i64>> par[MAX_N];
int sub[MAX_N], del[MAX_N];
i64 best_way[MAX_N];
int calc_subtree(int node, int p) {
sub[node] = 1;
for (auto to : g[node]) {
if (to.first != p && !del[to.first]) {
sub[node] += calc_subtree(to.first, node);
}
}
return sub[node];
}
int calc_centroid(int node, int p, const int tam) {
for (auto to : g[node]) {
if (!del[to.first] && to.first != p && sub[to.first] > tam / 2) {
return calc_centroid(to.first, node, tam);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |