#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
vector<int> x(N), y(N), c(N);
vector<int> state(N);
int nodecnt=0, n, pw=1;
int build(int l, int r) {
if(l >= r)return 0;
if(r < pw - n) {
return -1;
}
int mid = (l+r)/2;
int cur = ++nodecnt;
x[cur-1] = build(l, mid);
y[cur-1] = build(mid+1, r);
return -cur;
}
void ins(int i, int val) {
assert(i!=0);
if(state[-i]) {
state[-i]^=1;
if(y[-i-1] == 0) {
y[-i-1] = val;
}
else {
ins(y[-i-1], val);
}
}
else {
state[-i]^=1;
if(x[-i-1] == 0) {
x[-i-1] = val;
}
else {
ins(x[-i-1], val);
}
}
}
void create_circuit(int M, std::vector<int> A) {
pw = 1;
n = A.size();
c=vector<int>(M+1, -1);
while(pw < n) {
pw*=2;
}
build(0, pw-1);
for(int i = 1;i<n;i++) {
ins(-1, A[i]);
}
if(n%2 == 1)ins(-1,-1);
ins(-1,0);
c[0] = A[0];
while(x.size()>nodecnt)x.pop_back();
while(y.size()>nodecnt)y.pop_back();
answer(c, x, y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:54:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
54 | while(x.size()>nodecnt)x.pop_back();
| ~~~~~~~~^~~~~~~~
doll.cpp:55:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
55 | while(y.size()>nodecnt)y.pop_back();
| ~~~~~~~~^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
34 ms |
16984 KB |
Output is correct |
3 |
Correct |
52 ms |
16728 KB |
Output is correct |
4 |
Correct |
11 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
52 ms |
17268 KB |
Output is correct |
7 |
Incorrect |
8 ms |
15964 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
34 ms |
16984 KB |
Output is correct |
3 |
Correct |
52 ms |
16728 KB |
Output is correct |
4 |
Correct |
11 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
52 ms |
17268 KB |
Output is correct |
7 |
Incorrect |
8 ms |
15964 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
34 ms |
16984 KB |
Output is correct |
3 |
Correct |
52 ms |
16728 KB |
Output is correct |
4 |
Correct |
11 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
52 ms |
17268 KB |
Output is correct |
7 |
Incorrect |
8 ms |
15964 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
7 ms |
15964 KB |
Output is correct |
3 |
Correct |
8 ms |
15960 KB |
Output is correct |
4 |
Correct |
7 ms |
15960 KB |
Output is correct |
5 |
Correct |
9 ms |
15960 KB |
Output is correct |
6 |
Correct |
7 ms |
15964 KB |
Output is correct |
7 |
Correct |
7 ms |
15960 KB |
Output is correct |
8 |
Correct |
7 ms |
15960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
15964 KB |
Output is correct |
2 |
Correct |
58 ms |
16984 KB |
Output is correct |
3 |
Correct |
61 ms |
16988 KB |
Output is correct |
4 |
Correct |
79 ms |
17824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
15964 KB |
Output is correct |
2 |
Correct |
58 ms |
16984 KB |
Output is correct |
3 |
Correct |
61 ms |
16988 KB |
Output is correct |
4 |
Correct |
79 ms |
17824 KB |
Output is correct |
5 |
Correct |
87 ms |
19192 KB |
Output is correct |
6 |
Correct |
85 ms |
18940 KB |
Output is correct |
7 |
Correct |
88 ms |
18936 KB |
Output is correct |
8 |
Correct |
105 ms |
18680 KB |
Output is correct |
9 |
Correct |
61 ms |
16984 KB |
Output is correct |
10 |
Correct |
82 ms |
18680 KB |
Output is correct |
11 |
Correct |
93 ms |
18356 KB |
Output is correct |
12 |
Correct |
81 ms |
16988 KB |
Output is correct |
13 |
Correct |
59 ms |
16988 KB |
Output is correct |
14 |
Correct |
71 ms |
16988 KB |
Output is correct |
15 |
Correct |
61 ms |
16988 KB |
Output is correct |
16 |
Correct |
9 ms |
15940 KB |
Output is correct |
17 |
Correct |
60 ms |
16988 KB |
Output is correct |
18 |
Correct |
64 ms |
17132 KB |
Output is correct |
19 |
Correct |
59 ms |
17392 KB |
Output is correct |
20 |
Correct |
82 ms |
18372 KB |
Output is correct |
21 |
Correct |
89 ms |
18080 KB |
Output is correct |
22 |
Correct |
89 ms |
18336 KB |
Output is correct |