#include "doll.h"
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>
const int mxn = 1 << 19;
int n, k, t;
bool b[mxn];
vi f, u(mxn), v(mxn);
int bld(int l, int r){
if(l == r) return 0;
if(r < k - n) return -1;
int it = t++, mid = (l + r) / 2;
u[it] = bld(l, mid), v[it] = bld(mid + 1, r);
return -it - 1;
}
void add(int x, int y){
x = -x - 1;
int &z = b[x] ? v[x] : u[x];
b[x] ^= 1;
if(!z) z = y;
else add(z, y);
}
/*
void answer(vi f, vi u, vi v){
for(int i = 0; i < f.size(); i++){
cout << i << ": " << f[i] << endl;
}
for(int i = 0; i < u.size(); i++){
cout << (-i - 1) << ": " << u[i] << " " << v[i] << endl;
}
}
*/
void create_circuit(int m, vi a){
n = a.size(), k = 1 << (__lg(n - 1) + 1);
bld(0, k - 1);
for(int i = 1; i < n; i++) add(-1, a[i]);
if(n & 1) add(-1, -1);
add(-1, 0);
f.assign(m + 1, -1), u.resize(t), v.resize(t);
f[0] = a[0];
answer(f, u, v);
}
/*
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vi a(n);
for(int i = 0; i < n; i++) cin >> a[i];
create_circuit(m, a);
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
64 ms |
7160 KB |
Output is correct |
3 |
Correct |
50 ms |
6788 KB |
Output is correct |
4 |
Correct |
4 ms |
4300 KB |
Output is correct |
5 |
Correct |
19 ms |
5580 KB |
Output is correct |
6 |
Correct |
76 ms |
8016 KB |
Output is correct |
7 |
Correct |
4 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
64 ms |
7160 KB |
Output is correct |
3 |
Correct |
50 ms |
6788 KB |
Output is correct |
4 |
Correct |
4 ms |
4300 KB |
Output is correct |
5 |
Correct |
19 ms |
5580 KB |
Output is correct |
6 |
Correct |
76 ms |
8016 KB |
Output is correct |
7 |
Correct |
4 ms |
4300 KB |
Output is correct |
8 |
Correct |
91 ms |
8492 KB |
Output is correct |
9 |
Correct |
106 ms |
8772 KB |
Output is correct |
10 |
Correct |
173 ms |
10716 KB |
Output is correct |
11 |
Correct |
3 ms |
4300 KB |
Output is correct |
12 |
Correct |
3 ms |
4300 KB |
Output is correct |
13 |
Correct |
3 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
64 ms |
7160 KB |
Output is correct |
3 |
Correct |
50 ms |
6788 KB |
Output is correct |
4 |
Correct |
4 ms |
4300 KB |
Output is correct |
5 |
Correct |
19 ms |
5580 KB |
Output is correct |
6 |
Correct |
76 ms |
8016 KB |
Output is correct |
7 |
Correct |
4 ms |
4300 KB |
Output is correct |
8 |
Correct |
91 ms |
8492 KB |
Output is correct |
9 |
Correct |
106 ms |
8772 KB |
Output is correct |
10 |
Correct |
173 ms |
10716 KB |
Output is correct |
11 |
Correct |
3 ms |
4300 KB |
Output is correct |
12 |
Correct |
3 ms |
4300 KB |
Output is correct |
13 |
Correct |
3 ms |
4300 KB |
Output is correct |
14 |
Correct |
136 ms |
10336 KB |
Output is correct |
15 |
Correct |
102 ms |
8112 KB |
Output is correct |
16 |
Correct |
150 ms |
10076 KB |
Output is correct |
17 |
Correct |
4 ms |
4300 KB |
Output is correct |
18 |
Correct |
4 ms |
4300 KB |
Output is correct |
19 |
Correct |
4 ms |
4300 KB |
Output is correct |
20 |
Correct |
143 ms |
10412 KB |
Output is correct |
21 |
Correct |
3 ms |
4300 KB |
Output is correct |
22 |
Correct |
3 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
3 ms |
4300 KB |
Output is correct |
3 |
Correct |
3 ms |
4300 KB |
Output is correct |
4 |
Correct |
4 ms |
4300 KB |
Output is correct |
5 |
Correct |
4 ms |
4300 KB |
Output is correct |
6 |
Correct |
3 ms |
4300 KB |
Output is correct |
7 |
Correct |
3 ms |
4300 KB |
Output is correct |
8 |
Correct |
4 ms |
4300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
88 ms |
7616 KB |
Output is correct |
3 |
Correct |
89 ms |
7612 KB |
Output is correct |
4 |
Correct |
130 ms |
9280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4300 KB |
Output is correct |
2 |
Correct |
88 ms |
7616 KB |
Output is correct |
3 |
Correct |
89 ms |
7612 KB |
Output is correct |
4 |
Correct |
130 ms |
9280 KB |
Output is correct |
5 |
Correct |
137 ms |
9924 KB |
Output is correct |
6 |
Correct |
143 ms |
9828 KB |
Output is correct |
7 |
Correct |
142 ms |
9964 KB |
Output is correct |
8 |
Correct |
156 ms |
9572 KB |
Output is correct |
9 |
Correct |
110 ms |
7616 KB |
Output is correct |
10 |
Correct |
165 ms |
9492 KB |
Output is correct |
11 |
Correct |
141 ms |
9288 KB |
Output is correct |
12 |
Correct |
114 ms |
7608 KB |
Output is correct |
13 |
Correct |
96 ms |
7984 KB |
Output is correct |
14 |
Correct |
89 ms |
7992 KB |
Output is correct |
15 |
Correct |
92 ms |
8132 KB |
Output is correct |
16 |
Correct |
6 ms |
4428 KB |
Output is correct |
17 |
Correct |
93 ms |
7608 KB |
Output is correct |
18 |
Correct |
84 ms |
7612 KB |
Output is correct |
19 |
Correct |
84 ms |
7604 KB |
Output is correct |
20 |
Correct |
136 ms |
9340 KB |
Output is correct |
21 |
Correct |
135 ms |
9296 KB |
Output is correct |
22 |
Correct |
139 ms |
9232 KB |
Output is correct |