Submission #1160032

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11600322025-03-01 16:26:19Hamed_GhaffariRailway (BOI17_railway)C++20
0 / 100
38 ms23996 KiB
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define pb push_back
#define all(x) x.begin(), x.end()
const int MXN = 1e5+5;
const int LOG = 17;
int n, par[LOG][MXN], stt[MXN], fnt[MXN], timer;
vector<pii> g[MXN];
void dfs(int v) {
for(int i=1; i<LOG; i++)
par[i][v] = par[i-1][par[i-1][v]];
stt[v] = timer++;
for(auto [u, i] : g[v])
if(u!=par[0][v])
par[0][u]=v,
dfs(u);
fnt[v] = timer;
}
bool is_anc(int u, int v) { return stt[u]<=stt[v] && fnt[v]<=fnt[u]; };
int LCA(int u, int v) {
if(is_anc(u, v)) return u;
for(int i=LOG-1; i>=0; i--)
if(par[i][u] && !is_anc(par[i][u], v))
u = par[i][u];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...