# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441929 | parsabahrami | Birthday gift (IZhO18_treearray) | C++17 | 1060 ms | 32572 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.
/* I do it for the glory */
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define SZ(x) (int) x.size()
#define F first
#define S second
const int N = 2e5 + 10, MOD = 1e9 + 7, SQ = 500;
int H[N], P[19][N], A[N], B[N], M[N / SQ + 1][N], n, m, q;
vector<int> adj[N];
void preDFS(int v, int p = -1) {
if (!~p) P[0][v] = v;
for (int i = 1; i < 19; i++)
P[i][v] = P[i - 1][P[i - 1][v]];
for (int &u : adj[v])
if (u != p)
H[u] = H[v] + 1, P[0][u] = v, preDFS(u, v);
}
int LCA(int u, int v) {
if (H[u] < H[v]) swap(u, v);
for (int i = H[u] - H[v]; i; i -= i & -i)
u = P[__builtin_ctz(i)][u];
for (int i = 18; ~i; i--)
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... |