# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1011643 | biximo | Meetings 2 (JOI21_meetings2) | C++17 | 4081 ms | 44624 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>
#define N 200005
#define INF 1000000000
using namespace std;
int n, sz[N], dpt[N], tb[N][18];
vector<int> adj[N];
bool vs[N];
void size_DFS(int c, int p) {
sz[c] = 1;
for(int i = 1; i < 18; i ++) {
tb[c][i] = tb[tb[c][i-1]][i-1];
}
for(int i: adj[c]) {
if(i == p) continue;
dpt[i] = dpt[c]+1;
tb[i][0] = c;
size_DFS(i, c);
sz[c] += sz[i];
}
}
int jump(int a, int ds) {
for(int i = 0; i < 18; i ++) {
if(ds&1<<i) a = tb[a][i];
}
return a;
}
int LCA(int a, int b) {
if(dpt[a] != dpt[b]) {
if(dpt[a] < dpt[b]) swap(a,b);
a = jump(a, dpt[a]-dpt[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... |