#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) {
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:53:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | while(x.size()>nodecnt)x.pop_back();
| ~~~~~~~~^~~~~~~~
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(y.size()>nodecnt)y.pop_back();
| ~~~~~~~~^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
52 ms |
16988 KB |
Output is correct |
3 |
Correct |
33 ms |
16732 KB |
Output is correct |
4 |
Correct |
10 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
46 ms |
17240 KB |
Output is correct |
7 |
Incorrect |
7 ms |
15960 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
52 ms |
16988 KB |
Output is correct |
3 |
Correct |
33 ms |
16732 KB |
Output is correct |
4 |
Correct |
10 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
46 ms |
17240 KB |
Output is correct |
7 |
Incorrect |
7 ms |
15960 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15960 KB |
Output is correct |
2 |
Correct |
52 ms |
16988 KB |
Output is correct |
3 |
Correct |
33 ms |
16732 KB |
Output is correct |
4 |
Correct |
10 ms |
15960 KB |
Output is correct |
5 |
Correct |
12 ms |
16476 KB |
Output is correct |
6 |
Correct |
46 ms |
17240 KB |
Output is correct |
7 |
Incorrect |
7 ms |
15960 KB |
wrong serial number |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15964 KB |
Output is correct |
2 |
Correct |
7 ms |
15964 KB |
Output is correct |
3 |
Correct |
10 ms |
15964 KB |
Output is correct |
4 |
Correct |
9 ms |
16092 KB |
Output is correct |
5 |
Correct |
12 ms |
15964 KB |
Output is correct |
6 |
Correct |
7 ms |
15964 KB |
Output is correct |
7 |
Correct |
7 ms |
15960 KB |
Output is correct |
8 |
Correct |
11 ms |
15964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
15964 KB |
Output is correct |
2 |
Correct |
65 ms |
16984 KB |
Output is correct |
3 |
Correct |
69 ms |
16984 KB |
Output is correct |
4 |
Correct |
83 ms |
17816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
15964 KB |
Output is correct |
2 |
Correct |
65 ms |
16984 KB |
Output is correct |
3 |
Correct |
69 ms |
16984 KB |
Output is correct |
4 |
Correct |
83 ms |
17816 KB |
Output is correct |
5 |
Correct |
106 ms |
19192 KB |
Output is correct |
6 |
Correct |
99 ms |
18940 KB |
Output is correct |
7 |
Correct |
96 ms |
18908 KB |
Output is correct |
8 |
Correct |
92 ms |
18632 KB |
Output is correct |
9 |
Correct |
65 ms |
16988 KB |
Output is correct |
10 |
Correct |
79 ms |
18628 KB |
Output is correct |
11 |
Correct |
99 ms |
18168 KB |
Output is correct |
12 |
Correct |
61 ms |
16988 KB |
Output is correct |
13 |
Correct |
61 ms |
16988 KB |
Output is correct |
14 |
Correct |
65 ms |
16984 KB |
Output is correct |
15 |
Correct |
79 ms |
16980 KB |
Output is correct |
16 |
Correct |
10 ms |
15964 KB |
Output is correct |
17 |
Correct |
70 ms |
16976 KB |
Output is correct |
18 |
Correct |
74 ms |
16988 KB |
Output is correct |
19 |
Correct |
70 ms |
16976 KB |
Output is correct |
20 |
Correct |
123 ms |
18332 KB |
Output is correct |
21 |
Correct |
103 ms |
18092 KB |
Output is correct |
22 |
Correct |
83 ms |
18352 KB |
Output is correct |