# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51737 | SpaimaCarpatilor | Factories (JOI14_factories) | C++17 | 4351 ms | 180580 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;
int nr, rmq[20][1000009], lg[1000009], lev[500009], firstPos[500009], lastPos[500009], color[500009], ap[500009];
long long depth[500009], ans;
const long long INF = 1LL << 59;
vector < pair < int, int > > v[500009];
void dfs (int nod, int tata)
{
rmq[0][++nr] = nod, firstPos[nod] = nr;
for (auto it : v[nod])
if (it.first != tata)
depth[it.first] = depth[nod] + it.second,
lev[it.first] = lev[nod] + 1, dfs (it.first, nod),
rmq[0][++nr] = nod;
lastPos[nod] = nr;
}
int getHigher (int x, int y)
{
if (lev[x] > lev[y]) return y;
return x;
}
int getLCA (int x, int y)
{
x = firstPos[x], y = firstPos[y];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |