# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937793 | weakweakweak | Cat Exercise (JOI23_ho_t4) | C++14 | 203 ms | 46864 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;
int n, val[210000], fa[210000], vtoi[210000], par[210000][21], dep[210000] = {0};
long long ans[210000] = {0};
vector <int> e[210000];
int find (int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
void dfs(int i, int p) {
dep[i] = dep[p] + 1;
par[i][0] = p;
for (int j : e[i]) if (j != p) dfs(j, i);
}
int dis (int x, int y) {
int res = 0;
if (dep[x] > dep[y]) swap(x, y);
for (int i = 0; i <= 19; i++) if ((dep[y] - dep[x]) & (1 << i)) y = par[y][i], res += (1 << i);
if (x == y) return res;
for (int j = 19; j >= 0; j--) if (par[x][j] != par[y][j]) x = par[x][j], y = par[y][j], res += (1 << j) << 1;
res += 2;
return res;}
int main () {
//輸入、建圖
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |