#include<bits/stdc++.h>
#include "doll.h"
using namespace std;
vector<int> A, C, X, Y;
int S = 0;
int create_switch() {
X.push_back(-1);
Y.push_back(-1);
S++;
return -S;
}
void build(int trigger, vector<int> in) {
if((int)in.empty()) {
C[trigger] = 0;
return;
}
if((int)in.size() == 1) {
C[trigger] = A[in[0] + 1];
return;
}
int k = 1;
vector<int> order = {0};
while(k < (int)in.size()) {
if(k == 1) C[trigger] = create_switch();
else {
int len = S;
for(int i = len - k / 2; i < len; i++) {
X[i] = create_switch();
Y[i] = create_switch();
}
}
vector<int> new_ord;
for(int i = 0; i < k; i++)
new_ord.push_back(order[i]),
new_ord.push_back(order[i] + k);
order = new_ord;
k *= 2;
}
for(int i = S - k / 2; i < S; i++) {
int y = i - S + k / 2;
X[i] = (order[y * 2] < k - (int)in.size() ? C[trigger] : A[in[ order[2 * y] - k + (int)in.size() ] + 1]);
Y[i] = (order[y * 2 + 1] < k - (int)in.size() ? C[trigger] : A[in[ order[2 * y + 1] - k + (int)in.size() ] + 1]);
}
}
const int N = 1e5 + 10;
vector<int> g[N];
void create_circuit(int M, std::vector<int> a) {
C.resize(M + 1);
a.push_back(0);
A = a;
for(int i = 0; i < (int)A.size(); i++) {
g[A[i]].push_back(i);
}
C[0] = A[0];
for(int i = 1; i <= M; i++) {
build(i, g[i]);
}
if(S > 2 * (int)a.size()) {
1 / 0;
return;
}
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:64:11: warning: division by zero [-Wdiv-by-zero]
64 | 1 / 0;
| ~~^~~
doll.cpp:64:11: warning: statement has no effect [-Wunused-value]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
21 ms |
6608 KB |
Output is correct |
3 |
Correct |
18 ms |
6276 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8284 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
21 ms |
6608 KB |
Output is correct |
3 |
Correct |
18 ms |
6276 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8284 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
41 ms |
9284 KB |
Output is correct |
9 |
Correct |
42 ms |
9668 KB |
Output is correct |
10 |
Correct |
62 ms |
13128 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
21 ms |
6608 KB |
Output is correct |
3 |
Correct |
18 ms |
6276 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
9 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8284 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
41 ms |
9284 KB |
Output is correct |
9 |
Correct |
42 ms |
9668 KB |
Output is correct |
10 |
Correct |
62 ms |
13128 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
78 ms |
14928 KB |
Output is correct |
15 |
Correct |
41 ms |
8996 KB |
Output is correct |
16 |
Correct |
63 ms |
12048 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2644 KB |
Output is correct |
20 |
Correct |
69 ms |
13612 KB |
Output is correct |
21 |
Correct |
1 ms |
2644 KB |
Output is correct |
22 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
33 ms |
8976 KB |
Output is correct |
3 |
Partially correct |
51 ms |
13496 KB |
Output is partially correct |
4 |
Partially correct |
59 ms |
14468 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
33 ms |
8976 KB |
Output is correct |
3 |
Partially correct |
51 ms |
13496 KB |
Output is partially correct |
4 |
Partially correct |
59 ms |
14468 KB |
Output is partially correct |
5 |
Partially correct |
87 ms |
16636 KB |
Output is partially correct |
6 |
Partially correct |
113 ms |
17928 KB |
Output is partially correct |
7 |
Partially correct |
88 ms |
17392 KB |
Output is partially correct |
8 |
Partially correct |
86 ms |
18500 KB |
Output is partially correct |
9 |
Partially correct |
51 ms |
12072 KB |
Output is partially correct |
10 |
Partially correct |
96 ms |
18904 KB |
Output is partially correct |
11 |
Partially correct |
79 ms |
19320 KB |
Output is partially correct |
12 |
Partially correct |
55 ms |
13028 KB |
Output is partially correct |
13 |
Partially correct |
58 ms |
11708 KB |
Output is partially correct |
14 |
Partially correct |
59 ms |
11312 KB |
Output is partially correct |
15 |
Partially correct |
56 ms |
10960 KB |
Output is partially correct |
16 |
Partially correct |
3 ms |
2900 KB |
Output is partially correct |
17 |
Partially correct |
44 ms |
10444 KB |
Output is partially correct |
18 |
Partially correct |
44 ms |
11212 KB |
Output is partially correct |
19 |
Partially correct |
46 ms |
11680 KB |
Output is partially correct |
20 |
Partially correct |
66 ms |
14588 KB |
Output is partially correct |
21 |
Partially correct |
71 ms |
17152 KB |
Output is partially correct |
22 |
Partially correct |
59 ms |
13748 KB |
Output is partially correct |