#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> C, X, Y, Q[100100];
int l;
vector<int> nxt;
void build_tree(int i, int root, int H, int val, bool on){
if (on && (val&(1<<H))) X[i] = -root;
else if (H){
X.push_back(1e9);
Y.push_back(1e9);
X[i] = -(int)X.size();
build_tree((int)X.size()-1, root, H-1, val, 0);
}
if (H){
X.push_back(1e9);
Y.push_back(1e9);
Y[i] = -(int)X.size();
build_tree((int)X.size()-1, root, H-1, val, on&1);
}
}
bool ON[400400];
void getidx(int i){
ON[i] ^= 1;
if (ON[i]){
if (X[i]==1e9) X[i] = nxt[l++];
else getidx(-X[i]-1);
}
else{
if (Y[i]==1e9) Y[i] = nxt[l++];
else getidx(-Y[i]-1);
}
}
void create_circuit(int M, std::vector<int> A) {
int n = A.size();
C.resize(M+1, -1);
A.push_back(0);
C[0] = A[0];
if (n==1){
fill(C.begin()+1, C.end(), 0);
answer(C, X, Y);
return;
}
X.push_back(1e9); Y.push_back(1e9);
int t = 1, h = 0, R = (int)X.size()-1;
for (;t<n;t<<=1, h++);
build_tree(R, R+1, h-1, t-n, 1);
for (int i=1;i<(int)A.size();i++) nxt.push_back(A[i]);
while(l<(int)nxt.size()) getidx(R);
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
6648 KB |
Output is correct |
3 |
Correct |
33 ms |
6736 KB |
Output is correct |
4 |
Correct |
1 ms |
2636 KB |
Output is correct |
5 |
Correct |
9 ms |
3788 KB |
Output is correct |
6 |
Correct |
49 ms |
8680 KB |
Output is correct |
7 |
Correct |
1 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
6648 KB |
Output is correct |
3 |
Correct |
33 ms |
6736 KB |
Output is correct |
4 |
Correct |
1 ms |
2636 KB |
Output is correct |
5 |
Correct |
9 ms |
3788 KB |
Output is correct |
6 |
Correct |
49 ms |
8680 KB |
Output is correct |
7 |
Correct |
1 ms |
2636 KB |
Output is correct |
8 |
Correct |
61 ms |
9540 KB |
Output is correct |
9 |
Correct |
72 ms |
10004 KB |
Output is correct |
10 |
Correct |
100 ms |
13212 KB |
Output is correct |
11 |
Correct |
1 ms |
2636 KB |
Output is correct |
12 |
Correct |
1 ms |
2636 KB |
Output is correct |
13 |
Correct |
1 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2636 KB |
Output is correct |
2 |
Correct |
35 ms |
6648 KB |
Output is correct |
3 |
Correct |
33 ms |
6736 KB |
Output is correct |
4 |
Correct |
1 ms |
2636 KB |
Output is correct |
5 |
Correct |
9 ms |
3788 KB |
Output is correct |
6 |
Correct |
49 ms |
8680 KB |
Output is correct |
7 |
Correct |
1 ms |
2636 KB |
Output is correct |
8 |
Correct |
61 ms |
9540 KB |
Output is correct |
9 |
Correct |
72 ms |
10004 KB |
Output is correct |
10 |
Correct |
100 ms |
13212 KB |
Output is correct |
11 |
Correct |
1 ms |
2636 KB |
Output is correct |
12 |
Correct |
1 ms |
2636 KB |
Output is correct |
13 |
Correct |
1 ms |
2636 KB |
Output is correct |
14 |
Correct |
102 ms |
12748 KB |
Output is correct |
15 |
Correct |
65 ms |
8960 KB |
Output is correct |
16 |
Correct |
102 ms |
12488 KB |
Output is correct |
17 |
Correct |
1 ms |
2636 KB |
Output is correct |
18 |
Correct |
1 ms |
2636 KB |
Output is correct |
19 |
Correct |
1 ms |
2636 KB |
Output is correct |
20 |
Correct |
101 ms |
12912 KB |
Output is correct |
21 |
Correct |
2 ms |
2636 KB |
Output is correct |
22 |
Correct |
1 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2636 KB |
Output is correct |
2 |
Correct |
2 ms |
2636 KB |
Output is correct |
3 |
Correct |
1 ms |
2636 KB |
Output is correct |
4 |
Correct |
2 ms |
2636 KB |
Output is correct |
5 |
Correct |
1 ms |
2636 KB |
Output is correct |
6 |
Correct |
1 ms |
2636 KB |
Output is correct |
7 |
Correct |
1 ms |
2636 KB |
Output is correct |
8 |
Correct |
2 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
60 ms |
8632 KB |
Output is correct |
3 |
Correct |
72 ms |
8040 KB |
Output is correct |
4 |
Correct |
94 ms |
10952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2636 KB |
Output is correct |
2 |
Correct |
60 ms |
8632 KB |
Output is correct |
3 |
Correct |
72 ms |
8040 KB |
Output is correct |
4 |
Correct |
94 ms |
10952 KB |
Output is correct |
5 |
Correct |
100 ms |
12272 KB |
Output is correct |
6 |
Correct |
96 ms |
11980 KB |
Output is correct |
7 |
Correct |
102 ms |
12196 KB |
Output is correct |
8 |
Correct |
94 ms |
11788 KB |
Output is correct |
9 |
Correct |
60 ms |
7984 KB |
Output is correct |
10 |
Correct |
96 ms |
11620 KB |
Output is correct |
11 |
Correct |
105 ms |
11324 KB |
Output is correct |
12 |
Correct |
62 ms |
8304 KB |
Output is correct |
13 |
Correct |
58 ms |
9152 KB |
Output is correct |
14 |
Correct |
65 ms |
8764 KB |
Output is correct |
15 |
Correct |
65 ms |
8928 KB |
Output is correct |
16 |
Correct |
3 ms |
2764 KB |
Output is correct |
17 |
Correct |
57 ms |
8868 KB |
Output is correct |
18 |
Correct |
68 ms |
8872 KB |
Output is correct |
19 |
Correct |
65 ms |
8312 KB |
Output is correct |
20 |
Correct |
95 ms |
11584 KB |
Output is correct |
21 |
Correct |
92 ms |
11344 KB |
Output is correct |
22 |
Correct |
95 ms |
11300 KB |
Output is correct |