# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587245 | danikoynov | Factories (JOI14_factories) | C++14 | 4674 ms | 297760 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>
#include "factories.h"
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 10;
const ll inf = 1e18;
vector < pair < int, ll > > g[maxn];
int n, root, sub[maxn], used[maxn], par[maxn];
int f[2 * maxn], in[maxn], timer;
ll depth[maxn], cl[maxn];
void calc(int v, int p, bool st)
{
if (st)
{
f[++ timer] = v;
in[v] = timer;
}
sub[v] = 1;
for (pair < int, ll > nb : g[v])
{
int u = nb.first;
if (u == p || used[u])
continue;
if (st)
depth[u] = depth[v] + nb.second;
calc(u, v, st);
sub[v] += sub[u];
if (st)
f[++ timer] = 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... |