#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
int S = 0;
vector<int> X, Y;
vector<int> state;
int build(int n, int h){
if(h == 0) return 1;
int ind = S++;
X.resize(S);
Y.resize(S);
int k = (1<<(h-1));
vector<int> le, ri;
Y[ind] = build(min(k, n), h-1);
if(k >= n){
X[ind] = -1; // root
}
else{
X[ind] = build(n-k, h-1);
}
return -(ind+1);
}
int exec(){
int i = -1;
while(true){
int j = -i-1;
if(state[j]) i = Y[j];
else i = X[j];
state[j] ^= 1;
if(i == 1) return j;
if(i == -1) return -1;
}
}
void create_circuit(int M, vector<int> A) {
A.push_back(0);
int n = (int)A.size();
int h = (int)ceil(log2(n));
build(n, h);
state.resize(S);
int i = 0;
while(i < n){
int j = exec();
if(j >= 0){
if(state[j]) X[j] = A[i++];
else Y[j] = A[i++];
}
}
vector<int> C(M + 1, -1);
answer(C, X, Y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
51 ms |
4096 KB |
Output is correct |
3 |
Correct |
36 ms |
4368 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
13 ms |
1364 KB |
Output is correct |
6 |
Correct |
55 ms |
6208 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
51 ms |
4096 KB |
Output is correct |
3 |
Correct |
36 ms |
4368 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
13 ms |
1364 KB |
Output is correct |
6 |
Correct |
55 ms |
6208 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
75 ms |
7896 KB |
Output is correct |
9 |
Correct |
78 ms |
8436 KB |
Output is correct |
10 |
Correct |
108 ms |
12132 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
51 ms |
4096 KB |
Output is correct |
3 |
Correct |
36 ms |
4368 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
13 ms |
1364 KB |
Output is correct |
6 |
Correct |
55 ms |
6208 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
75 ms |
7896 KB |
Output is correct |
9 |
Correct |
78 ms |
8436 KB |
Output is correct |
10 |
Correct |
108 ms |
12132 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
296 KB |
Output is correct |
14 |
Correct |
111 ms |
11616 KB |
Output is correct |
15 |
Correct |
71 ms |
7384 KB |
Output is correct |
16 |
Correct |
110 ms |
11316 KB |
Output is correct |
17 |
Correct |
0 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
117 ms |
11820 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
66 ms |
5560 KB |
Output is correct |
3 |
Correct |
62 ms |
5592 KB |
Output is correct |
4 |
Correct |
96 ms |
8368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
66 ms |
5560 KB |
Output is correct |
3 |
Correct |
62 ms |
5592 KB |
Output is correct |
4 |
Correct |
96 ms |
8368 KB |
Output is correct |
5 |
Correct |
112 ms |
9772 KB |
Output is correct |
6 |
Correct |
104 ms |
9408 KB |
Output is correct |
7 |
Correct |
106 ms |
9528 KB |
Output is correct |
8 |
Correct |
97 ms |
9140 KB |
Output is correct |
9 |
Correct |
62 ms |
5536 KB |
Output is correct |
10 |
Correct |
99 ms |
9148 KB |
Output is correct |
11 |
Correct |
97 ms |
8728 KB |
Output is correct |
12 |
Correct |
64 ms |
5832 KB |
Output is correct |
13 |
Correct |
67 ms |
6196 KB |
Output is correct |
14 |
Correct |
71 ms |
6452 KB |
Output is correct |
15 |
Correct |
70 ms |
6368 KB |
Output is correct |
16 |
Correct |
2 ms |
468 KB |
Output is correct |
17 |
Correct |
77 ms |
6148 KB |
Output is correct |
18 |
Correct |
64 ms |
5740 KB |
Output is correct |
19 |
Correct |
65 ms |
5824 KB |
Output is correct |
20 |
Correct |
104 ms |
9016 KB |
Output is correct |
21 |
Correct |
100 ms |
8740 KB |
Output is correct |
22 |
Correct |
99 ms |
8860 KB |
Output is correct |