# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394089 | Sundavar | Railway (BOI17_railway) | C++14 | 366 ms | 37000 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>
using namespace std;
typedef pair<int,int> pii;
int X = 18;
struct node{
vector<pii> to;
vector<int> father = *new vector<int>(X);
int with = -1, cnt = 0, d = -1, out = 0;
bool was = false;
};
vector<node> graph;
bool sortFunc(int a, int b){
return graph[a].out < graph[b].out;
}
int in = 0;
void DFS(int curr, int father){
graph[curr].was = true;
graph[curr].father[0] = father;
graph[curr].d = graph[father].d + 1;
for(int i = 1; i < X; i++)
graph[curr].father[i] = graph[graph[curr].father[i-1]].father[i-1];
for(pii& to : graph[curr].to)
if(!graph[to.first].was)
DFS(to.first, curr), graph[to.first].with = to.second;
graph[curr].out = in++;
graph[curr].was = false;
}
int lca(int a, int b){
if(graph[a].d < graph[b].d) swap(a,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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |