Submission #937793

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9377932024-03-04 13:16:10weakweakweakCat Exercise (JOI23_ho_t4)C++14
100 / 100
203 ms46864 KiB
#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++) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...
#Verdict Execution timeMemoryGrader output
Fetching results...