#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
int tree[MAXN*4];
int cal[MAXN*4];
int id[MAXN*4];
void create_circuit(int M, std::vector<int> A) {
int n = (int)A.size();
vector<int> C;
vector<int> X;
vector<int> Y;
C = vector<int> (M+1);
if(n==1){
C[0] = A[0];
answer(C,X,Y);
return;
}
int base = 1;
for(;base<n;base<<=1);
for(int i=base-1;i>=base-n;i--){
tree[i+base] = 1;
}
for(int i=base-1;i>=1;i--){
tree[i] = tree[(i<<1)]|tree[(i<<1)|1];
}
vector<int> ord;
int cur = 1;
for(int i=0;i<base;i++){
cur = 1;
while(cur<base){
if(cal[cur]){
cal[cur] = 0;
cur<<=1;
cur|=1;
}
else {
cal[cur] = 1;
cur<<=1;
}
}
if(tree[cur]){
ord.push_back(cur-base);
}
}
assert((int)ord.size()==n);
int cnt = 0;
for(int i=1;i<base;i++){
if(tree[i]){
cnt++;
id[i] = -cnt;
}
}
for(int i=0;i<n;i++){
if(i==n-1)id[ord[i]+base] = 0;
else id[ord[i]+base] = A[i+1];
}
C[0] = A[0];
for(int i=1;i<=M;i++){
C[i] = -1;
}
X = vector<int> (cnt);
Y = vector<int> (cnt);
int cidx = 0;
for(int i=1;i<base;i++){
if(tree[i]){
if(tree[(i<<1)]){
X[cidx] = id[(i<<1)];
}
else {
X[cidx] = -1;
}
if(tree[(i<<1)|1]){
Y[cidx] = id[(i<<1)|1];
}
else {
Y[cidx] = -1;
}
cidx++;
}
}
answer(C,X,Y);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
41 ms |
5704 KB |
Output is correct |
3 |
Correct |
42 ms |
5908 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
11 ms |
1484 KB |
Output is correct |
6 |
Correct |
65 ms |
7944 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
41 ms |
5704 KB |
Output is correct |
3 |
Correct |
42 ms |
5908 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
11 ms |
1484 KB |
Output is correct |
6 |
Correct |
65 ms |
7944 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
68 ms |
9148 KB |
Output is correct |
9 |
Correct |
88 ms |
11208 KB |
Output is correct |
10 |
Correct |
107 ms |
14392 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
41 ms |
5704 KB |
Output is correct |
3 |
Correct |
42 ms |
5908 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
11 ms |
1484 KB |
Output is correct |
6 |
Correct |
65 ms |
7944 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
68 ms |
9148 KB |
Output is correct |
9 |
Correct |
88 ms |
11208 KB |
Output is correct |
10 |
Correct |
107 ms |
14392 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
111 ms |
13992 KB |
Output is correct |
15 |
Correct |
73 ms |
10540 KB |
Output is correct |
16 |
Correct |
98 ms |
13868 KB |
Output is correct |
17 |
Correct |
0 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 |
102 ms |
14116 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 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 |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
55 ms |
8552 KB |
Output is correct |
3 |
Correct |
71 ms |
9564 KB |
Output is correct |
4 |
Correct |
88 ms |
13392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
55 ms |
8552 KB |
Output is correct |
3 |
Correct |
71 ms |
9564 KB |
Output is correct |
4 |
Correct |
88 ms |
13392 KB |
Output is correct |
5 |
Correct |
99 ms |
13736 KB |
Output is correct |
6 |
Correct |
101 ms |
13480 KB |
Output is correct |
7 |
Correct |
95 ms |
13552 KB |
Output is correct |
8 |
Correct |
93 ms |
13368 KB |
Output is correct |
9 |
Correct |
69 ms |
9552 KB |
Output is correct |
10 |
Correct |
93 ms |
13368 KB |
Output is correct |
11 |
Correct |
90 ms |
13336 KB |
Output is correct |
12 |
Correct |
68 ms |
9900 KB |
Output is correct |
13 |
Correct |
59 ms |
8604 KB |
Output is correct |
14 |
Correct |
71 ms |
10288 KB |
Output is correct |
15 |
Correct |
72 ms |
10508 KB |
Output is correct |
16 |
Correct |
3 ms |
588 KB |
Output is correct |
17 |
Correct |
57 ms |
8608 KB |
Output is correct |
18 |
Correct |
56 ms |
8476 KB |
Output is correct |
19 |
Correct |
68 ms |
9904 KB |
Output is correct |
20 |
Correct |
96 ms |
13312 KB |
Output is correct |
21 |
Correct |
93 ms |
13368 KB |
Output is correct |
22 |
Correct |
91 ms |
13348 KB |
Output is correct |