#include "doll.h"
#include <iostream>
#include <array>
#include <vector>
#define ll int
using namespace std;
ll n, k, cnt;
bool B[400000];
vector <ll> C, X, Y;
ll solve(ll l, ll r) {
ll id = cnt++, mid = (l+r)/2;
X.push_back(-1);
Y.push_back(-1);
if (n < l) {
X[id] = -(id+1);
Y[id] = -1;
return id;
}
else if (l == r) return 0;
X[id] = solve(l, mid);
Y[id] = solve(mid+1, r);
return id;
}
void get(ll x) {
x *= -1;
if (!B[x]) {
B[x] ^= 1;
if (X[x] != 0) get(X[x]);
else {
X[x] = k;
return;
}
}
else {
B[x] ^= 1;
if (Y[x] != 0) get(Y[x]);
else {
Y[x] = k;
return;
}
}
}
void create_circuit(int M, std::vector<int> A) {
n = A.size() + 1;
for (int i=0; i<=M; ++i) C.push_back(-1);
for (int i=18; i>=0; --i) {
if (n <= (1LL << i)) k = (1LL << i);
}
solve(1, k);
for (int i=1; i<n; ++i) {
k = i;
get(-1);
}
k = 0;
get(-1);
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |