# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076331 | fryingduc | Putovanje (COCI20_putovanje) | C++17 | 92 ms | 27872 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;
const int maxn = 2e5 + 5;
const int lg = 19;
int n, ca[maxn], cb[maxn];
vector<int> g[maxn];
int edge_u[maxn], edge_v[maxn], edge_ca[maxn], edge_cb[maxn];
int par[maxn];
int h[maxn];
int f[maxn];
int up[maxn][lg + 1];
void pre_dfs(int u, int prev) {
for(auto v:g[u]) {
if(v == prev) continue;
par[v] = u;
up[v][0] = u;
h[v] = h[u] + 1;
for(int i = 1; i <= lg; ++i) {
up[v][i] = up[up[v][i - 1]][i - 1];
}
pre_dfs(v, u);
}
}
int lca(int u, int v) {
if(h[u] < h[v]) swap(u, v);
for(int i = lg; i >= 0; --i) {
if((h[u] - h[v]) >> i & 1) u = up[u][i];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |