# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209262 | dennisstar | Synchronization (JOI13_synchronization) | C++17 | 390 ms | 29432 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>
#define eb emplace_back
using namespace std;
typedef vector<int> vim;
const int MX = 100005;
int N, M, Q, c, X[MX], Y[MX], Z[MX], lst[MX];
int in[MX], out[MX], chk[MX];
vim adj[MX], spt[MX];
int F[MX];
void upd(int t, int v) { while (t<=N) F[t]+=v, t+=t&-t; }
int get(int t) { int r=0; while (t) r+=F[t], t-=t&-t; return r; }
void dfs(int n, int p) {
spt[n].eb(p); in[n]=++c;
for (int i=0; i<spt[spt[n][i]].size(); i++) spt[n].eb(spt[spt[n][i]][i]);
for (auto &i:adj[n]) if (i!=p) dfs(i, n);
out[n]=c+1;
}
int gp(int t) {
int x=get(in[t]);
for (int i=20; i>=0; i--) if (i<spt[t].size()&&x==get(in[spt[t][i]])) t=spt[t][i];
return t;
}
int main() {
cin.tie(0)->sync_with_stdio(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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |