# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261881 | Kastanda | Capital City (JOI20_capital_city) | C++11 | 475 ms | 66036 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.
// M
#include<bits/stdc++.h>
using namespace std;
const int N = 200005, LG = 18;
int n, k, cp, A[N], H[N], P[N][LG], M[N], C[N], SZ[N], lca[N];
vector < int > TP, Adj[N], Out[N], In[N], V[N];
void DFS(int v, int p)
{
P[v][0] = p;
for (int j = 1; j < LG; j ++)
P[v][j] = P[P[v][j - 1]][j - 1];
for (int u : Adj[v])
if (u != p)
H[u] = H[v] + 1, DFS(u, v);
}
inline int LCA(int v, int u)
{
if (H[v] < H[u])
swap(v, u);
for (int i = 0; i < LG; i ++)
if ((H[v] - H[u]) >> i & 1)
v = P[v][i];
if (v == u)
return v;
for (int i = LG - 1; ~ i; i --)
if (P[v][i] != P[u][i])
v = P[v][i], u = P[u][i];
return P[v][0];
}
void DFS2(int v)
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |