#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
vector<int> X(0), Y(0);
int seq = 0;
int createSwitch(int x, int y){
X.push_back(x);
Y.push_back(y);
--seq;
return seq;
}
int createTree(vector<int> &V){
int n = V.size();
if(n == 1){
return V[0];
}
bool same = true;
for(int i = 0; i < n - 1; ++i){
if(V[i] != V[i + 1]){
same = false;
break;
}
}
if(same){
return V[0];
}
vector<int> x(0), y(0);
for(int i = 0; i < n; ++i){
if(i % 2 == 0){
x.push_back(V[i]);
} else {
y.push_back(V[i]);
}
}
int ix = createTree(x);
int iy = createTree(y);
return createSwitch(ix, iy);
}
int revBit(int a, int k){
int b = 0;
while(k--){
b <<= 1;
b |= (a & 1);
a >>= 1;
}
return b;
}
void create_circuit(int M, vector<int> A){
int n = A.size();
int nExp = 0;
while((1 << nExp) < n){
++nExp;
}
A.push_back(0);
vector<int> V(1 << nExp, 0);
for(int i = 0; i < (1 << nExp) - n; ++i){
V[revBit(i, nExp)] = 1e9;
}
int idx = 1;
for(int i = 0; i < (1 << nExp); ++i){
if(V[i] == 0){
V[i] = A[idx];
++idx;
}
}
int root = createTree(V);
vector<int> C(M + 1, root);
C[0] = A[0];
for(auto &x : X){
if(x == 1e9){
x = root;
}
}
for(auto &y : Y){
if(y == 1e9){
y = root;
}
}
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
49 ms |
4884 KB |
Output is correct |
3 |
Correct |
48 ms |
4360 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
16 ms |
1356 KB |
Output is correct |
6 |
Correct |
73 ms |
6452 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
49 ms |
4884 KB |
Output is correct |
3 |
Correct |
48 ms |
4360 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
16 ms |
1356 KB |
Output is correct |
6 |
Correct |
73 ms |
6452 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
104 ms |
7704 KB |
Output is correct |
9 |
Correct |
103 ms |
8280 KB |
Output is correct |
10 |
Correct |
125 ms |
10516 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
49 ms |
4884 KB |
Output is correct |
3 |
Correct |
48 ms |
4360 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
16 ms |
1356 KB |
Output is correct |
6 |
Correct |
73 ms |
6452 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
104 ms |
7704 KB |
Output is correct |
9 |
Correct |
103 ms |
8280 KB |
Output is correct |
10 |
Correct |
125 ms |
10516 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
2 ms |
204 KB |
Output is correct |
14 |
Correct |
139 ms |
9996 KB |
Output is correct |
15 |
Correct |
107 ms |
6780 KB |
Output is correct |
16 |
Correct |
131 ms |
9396 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
120 ms |
10080 KB |
Output is correct |
21 |
Correct |
2 ms |
208 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
29 ms |
2860 KB |
Output is correct |
3 |
Correct |
30 ms |
4396 KB |
Output is correct |
4 |
Correct |
48 ms |
4936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
29 ms |
2860 KB |
Output is correct |
3 |
Correct |
30 ms |
4396 KB |
Output is correct |
4 |
Correct |
48 ms |
4936 KB |
Output is correct |
5 |
Correct |
122 ms |
9232 KB |
Output is correct |
6 |
Correct |
120 ms |
8988 KB |
Output is correct |
7 |
Correct |
153 ms |
9060 KB |
Output is correct |
8 |
Correct |
122 ms |
8844 KB |
Output is correct |
9 |
Correct |
71 ms |
5796 KB |
Output is correct |
10 |
Correct |
127 ms |
8632 KB |
Output is correct |
11 |
Correct |
127 ms |
8412 KB |
Output is correct |
12 |
Correct |
81 ms |
6280 KB |
Output is correct |
13 |
Correct |
82 ms |
6820 KB |
Output is correct |
14 |
Correct |
110 ms |
6720 KB |
Output is correct |
15 |
Correct |
85 ms |
6776 KB |
Output is correct |
16 |
Correct |
4 ms |
460 KB |
Output is correct |
17 |
Correct |
71 ms |
6500 KB |
Output is correct |
18 |
Correct |
82 ms |
6468 KB |
Output is correct |
19 |
Correct |
99 ms |
6208 KB |
Output is correct |
20 |
Correct |
127 ms |
8696 KB |
Output is correct |
21 |
Correct |
128 ms |
8448 KB |
Output is correct |
22 |
Correct |
115 ms |
8428 KB |
Output is correct |