# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972690 | sofija6 | Two Currencies (JOI23_currencies) | C++14 | 3165 ms | 179108 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 ll long long
#define MAXN 100010
#define logn 17
#define MAXV 20000010
using namespace std;
ll a[MAXN],b[MAXN],in[MAXN],out[MAXN],t=1,up[MAXN][logn],leftt[MAXV],rightt[MAXV],ind=1,root[MAXN];
pair<ll,ll> val[MAXV];
map<ll,ll> valc,revvalc;
vector<ll> G[MAXN];
void DFS_Init(ll i,ll p)
{
in[i]=t++;
up[i][0]=p;
for (ll j=1;j<logn;j++)
up[i][j]=up[up[i][j-1]][j-1];
for (ll next : G[i])
{
if (next!=p)
DFS_Init(next,i);
}
out[i]=t++;
}
bool Is_Ancestor(ll u,ll v)
{
return in[u]<=in[v] && out[u]>=out[v];
}
ll LCA(ll u,ll v)
{
if (Is_Ancestor(u,v))
# | 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... |