# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
519219 | amunduzbaev | Factories (JOI14_factories) | C++14 | 2664 ms | 161304 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;
#ifndef EVAL
#include "grader.cpp"
#endif
#include "factories.h"
#define ar array
const int M = 5e5 + 5;
vector<ar<int, 2>> edges[M];
int tin[M], tout[M], t, par[M][20];
long long d[M];
void dfs(int u, int p = -1){
tin[u] = ++t;
for(int i=1;i<20;i++) par[u][i] = par[par[u][i-1]][i-1];
for(auto x : edges[u]){
if(x[0] == p) continue;
d[x[0]] = d[u] + x[1];
par[x[0]][0] = u;
dfs(x[0], u);
} tout[u] = t;
}
int is[M];
bool iis(int a, int b) { return (tin[a] <= tin[b] && tout[b] <= tout[a]); }
int lca(int a, int b){
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |