#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int MX = 4e5 + 100;
int c[MX], x[MX], y[MX];
bool GG[MX];
int ptr;
int build(vector<int> v) {
if(*max_element(v.begin(), v.end()) ==
*min_element(v.begin(), v.end())) return v[0];
vector<int> a, b;
int p = --ptr;
for(int i = 0; i < v.size(); i ++) {
if(i & 1) b.push_back(v[i]);
else a.push_back(v[i]);
}
x[-p] = build(a);
y[-p] = build(b);
return p;
}
void create_circuit(int n, vector<int> v) {
int ttt = v.size();
c[0] = v[0];
int k = 1 << __lg(v.size() * 2 - 1);
int need = k - v.size();
auto f = [&](int v) {
int pp = 0;
for(int j = 0; j < __lg(k); j ++) {
if(v & (1 << j)) pp += 1 << (__lg(k) - j - 1);
}
return pp;
};
vector<int> tmp(k, 0);
v.push_back(0);
for(int i = 0; i < need; i ++) tmp[f(i)] = -1;
for(int i = k - 1; i >= 0; i --) {
if(!tmp[i]) tmp[i] = v.back(), v.pop_back();
}
int t = build(tmp);
for(int i = 1; i <= n; i ++) c[i] = -1;
for(int i = 1; i <= -ptr + 1; i ++) {
if(x[i] == -1) x[i] = t;
if(y[i] == -1) y[i] = t;
}
for(int i = 0; i <= n; i ++) {
if(c[i] == -1) c[i] = t;
}
answer(
vector<int>(c, c + 1 + n),
vector<int>(x + 1, x + 1 -ptr),
vector<int>(y + 1, y + 1 -ptr)
);
}
Compilation message
doll.cpp: In function 'int build(std::vector<int>)':
doll.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i = 0; i < v.size(); i ++) {
| ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:22:6: warning: unused variable 'ttt' [-Wunused-variable]
22 | int ttt = v.size();
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
53 ms |
4244 KB |
Output is correct |
3 |
Correct |
59 ms |
4116 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
98 ms |
6092 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
53 ms |
4244 KB |
Output is correct |
3 |
Correct |
59 ms |
4116 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
98 ms |
6092 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
91 ms |
7068 KB |
Output is correct |
9 |
Correct |
106 ms |
7760 KB |
Output is correct |
10 |
Correct |
145 ms |
10640 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
53 ms |
4244 KB |
Output is correct |
3 |
Correct |
59 ms |
4116 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
98 ms |
6092 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
91 ms |
7068 KB |
Output is correct |
9 |
Correct |
106 ms |
7760 KB |
Output is correct |
10 |
Correct |
145 ms |
10640 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
150 ms |
9600 KB |
Output is correct |
15 |
Correct |
106 ms |
7500 KB |
Output is correct |
16 |
Correct |
157 ms |
9432 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 |
168 ms |
9744 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 |
204 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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
3912 KB |
Output is correct |
3 |
Correct |
46 ms |
6464 KB |
Output is correct |
4 |
Correct |
46 ms |
6944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
20 ms |
3912 KB |
Output is correct |
3 |
Correct |
46 ms |
6464 KB |
Output is correct |
4 |
Correct |
46 ms |
6944 KB |
Output is correct |
5 |
Correct |
142 ms |
9452 KB |
Output is correct |
6 |
Correct |
143 ms |
9268 KB |
Output is correct |
7 |
Correct |
145 ms |
9280 KB |
Output is correct |
8 |
Correct |
141 ms |
9108 KB |
Output is correct |
9 |
Correct |
88 ms |
7124 KB |
Output is correct |
10 |
Correct |
128 ms |
8372 KB |
Output is correct |
11 |
Correct |
152 ms |
8660 KB |
Output is correct |
12 |
Correct |
102 ms |
7416 KB |
Output is correct |
13 |
Correct |
111 ms |
6056 KB |
Output is correct |
14 |
Correct |
103 ms |
7468 KB |
Output is correct |
15 |
Correct |
109 ms |
7496 KB |
Output is correct |
16 |
Correct |
4 ms |
460 KB |
Output is correct |
17 |
Correct |
103 ms |
5868 KB |
Output is correct |
18 |
Correct |
86 ms |
5688 KB |
Output is correct |
19 |
Correct |
143 ms |
7488 KB |
Output is correct |
20 |
Correct |
161 ms |
8964 KB |
Output is correct |
21 |
Correct |
146 ms |
8736 KB |
Output is correct |
22 |
Correct |
167 ms |
8756 KB |
Output is correct |