#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) {
if (l == r && (n > l || l == k)) return 0;
ll id = cnt++, mid = (l+r)/2;
//cout << id << " " << l << " " << r << endl;
X.push_back(-1);
Y.push_back(-1);
if (n <= l && r < k) {
X[id] = -(id+1);
Y[id] = -1;
return id+1;
}
X[id] = -solve(l, mid);
Y[id] = -solve(mid+1, r);
//cout << id+1 << " * " << X[id] << " " << Y[id] << endl;
return id+1;
}
void get(ll x) {
//cout << x << " ";
x *= -1;
--x;
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 = A[i-1];
get(-1);
//cout << endl;
}
k = 0;
get(-1);
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Partially correct |
56 ms |
6204 KB |
Output is partially correct |
3 |
Partially correct |
51 ms |
6072 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
8368 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
Output is partially correct |
2 |
Partially correct |
56 ms |
6204 KB |
Output is partially correct |
3 |
Partially correct |
51 ms |
6072 KB |
Output is partially correct |
4 |
Partially correct |
78 ms |
8368 KB |
Output is partially correct |
5 |
Partially correct |
88 ms |
9244 KB |
Output is partially correct |
6 |
Partially correct |
91 ms |
8840 KB |
Output is partially correct |
7 |
Partially correct |
81 ms |
8968 KB |
Output is partially correct |
8 |
Partially correct |
81 ms |
8684 KB |
Output is partially correct |
9 |
Partially correct |
52 ms |
6076 KB |
Output is partially correct |
10 |
Partially correct |
78 ms |
8808 KB |
Output is partially correct |
11 |
Partially correct |
78 ms |
8300 KB |
Output is partially correct |
12 |
Partially correct |
52 ms |
6500 KB |
Output is partially correct |
13 |
Partially correct |
54 ms |
6936 KB |
Output is partially correct |
14 |
Partially correct |
54 ms |
6928 KB |
Output is partially correct |
15 |
Partially correct |
55 ms |
7096 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
604 KB |
Output is partially correct |
17 |
Correct |
48 ms |
5596 KB |
Output is correct |
18 |
Partially correct |
51 ms |
6328 KB |
Output is partially correct |
19 |
Partially correct |
53 ms |
6472 KB |
Output is partially correct |
20 |
Partially correct |
79 ms |
8464 KB |
Output is partially correct |
21 |
Partially correct |
80 ms |
8300 KB |
Output is partially correct |
22 |
Partially correct |
84 ms |
8464 KB |
Output is partially correct |