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 "doll.h"
using namespace std;
const int maxn = 2e5 + 2;
int state [maxn * 2];
vector<int> x(2 * maxn), y(2 * maxn);
int n, k, depth, ct;
int dfs(int l, int r) {
if (l >= n) return -1;
if (r - l > 1) {
int mid = (l + r) / 2, u = ct++;
y[u] = dfs(l, mid);
x[u] = dfs(mid, r);
return -u-1;
}
return 1;
}
void create_circuit(int m, vector<int> a) {
a.push_back(0);
n = a.size();
vector<int> c(m + 1, -1);
for (int i = 0; i < 30; i++){
if ((1 << i) >= n) {
depth = i;
break;
}
}
k = (1 << depth);
dfs(0, k);
for (int i: a) {
int node = 0;
while (node >= 0) {
int &next = state[node] ? y[node]: x[node];
state[node]^=1;
if (next >= 0) next = i, node = -1;
node = -next-1;
}
}
x.resize(ct);
y.resize(ct);
answer(c, x, y);
}
# | 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... |