# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
783344 | fuad27 | Two Currencies (JOI23_currencies) | C++17 | 978 ms | 36920 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.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
using namespace std;
const int N=100'010,L=20;
vector<pair<int,int>> g[N];
int up[N][L];
int tin[N], tout[N],depth[N];
int tinn[N];
int tim=1;
void dfs(int at, int p) {
up[at][0]=p;
for(int i = 1;i<L;i++) {
up[at][i]=up[up[at][i-1]][i-1];
}
for(auto to:g[at]) {
if(to.first==p)continue;
tinn[to.first]=tim;
tin[to.second]=tim++;
depth[to.first]=depth[at]+1;
dfs(to.first,at);
tout[to.second]=tim++;
}
}
int lca(int a, int b) {
if(depth[a]<depth[b])swap(a,b);
int k=depth[a]-depth[b];
for(int i = L-1;i>=0;i--) {
if(k&(1<<i))a=up[a][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... |