# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
389240 | syl123456 | Easter Eggs (info1cup17_eastereggs) | C++17 | 17 ms | 584 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>
#include "grader.h"
using namespace std;
vector<vector<int>> g, pa;
vector<int> dep, ord;
void dfs(int i, int p) {
pa[i][0] = p;
ord.push_back(i);
dep[i] = dep[p] + 1;
for (int j : g[i]) if (j != p)
dfs(j, i);
}
int lca(int i, int j) {
if (dep[i] < dep[j]) swap(i, j);
for (int ii = 9; ~ii; --ii) if (dep[pa[i][ii]] >= dep[j])
i = pa[i][ii];
for (int ii = 9; ~ii; --ii) if (pa[i][ii] != pa[j][ii])
i = pa[i][ii], j = pa[j][ii];
return i == j ? i : pa[i][0];
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
g.assign(N, vector<int>()), pa.assign(N, vector<int>(10));
dep.resize(N), dep[0] = -1;
for (auto i : bridges) {
int x = i.first - 1, y = i.second - 1;
g[x].push_back(y), g[y].push_back(x);
}
dfs(0, 0);
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... |