#include "doll.h"
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define size(x) (int)(x.size())
using namespace std;
vector<vector<int>> adj;
vector<int> C, X, Y;
int cnt = -1;
void divide(vector<int> *a) {
if (size((*a)) == 2) {
X.pb((*a)[0]);
Y.pb((*a)[1]);
return;
}
vector<int> b, c;
for (int i = 0; i < size((*a)); i++) {
if (i & 1) c.pb( (*a)[i]);
else b.pb((*a)[i]);
}
X.pb(cnt); cnt--; Y.pb(0); int n = size(Y);
divide(&b);
Y[n - 1] = cnt; cnt--;
divide(&c);
}
void create_circuit(int M, vector<int> A) {
C.resize(M + 1);
int N = size(A);
int fact = 1, i = 0, last = 0;
vector<vector<int>> div;
div.push_back(A);
while (fact <= N) {
cnt--;
Y.push_back(last);
last = -size(Y);
if (N & (1 << i)) {
vector<vector<int>> newDiv;
vector<int> vec;
for (auto x : div) {
if (size(x) - 1) newDiv.push_back(vector<int>(x.begin(), x.begin() + size(x) / 2));
if (size(x) - 1) newDiv.push_back(vector<int>(x.begin() + size(x) / 2 + 1, x.end()));
vec.push_back(x[size(x) / 2]);
}
swap(div, newDiv);
if (i) {
X.push_back(cnt);
cnt--;
divide(&vec);
}
else X.push_back(vec[0]);
}
else {
X.push_back(0);
vector<vector<int>> newDiv;
for (auto x : div) {
newDiv.push_back(vector<int>(x.begin(), x.begin() + size(x) / 2));
newDiv.push_back(vector<int>(x.begin() + size(x) / 2, x.end()));
}
swap(div, newDiv);
}
fact <<= 1;
i++;
}
for (int i = 0; i <= M; i++) C[i] = last;
for (int& x: X) if (!x) x = last;
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
7380 KB |
Output is correct |
3 |
Correct |
30 ms |
7216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
1492 KB |
Output is correct |
6 |
Correct |
40 ms |
8732 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
7380 KB |
Output is correct |
3 |
Correct |
30 ms |
7216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
1492 KB |
Output is correct |
6 |
Correct |
40 ms |
8732 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
57 ms |
13972 KB |
Output is correct |
9 |
Correct |
57 ms |
14124 KB |
Output is correct |
10 |
Correct |
76 ms |
17256 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
7380 KB |
Output is correct |
3 |
Correct |
30 ms |
7216 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
1492 KB |
Output is correct |
6 |
Correct |
40 ms |
8732 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
57 ms |
13972 KB |
Output is correct |
9 |
Correct |
57 ms |
14124 KB |
Output is correct |
10 |
Correct |
76 ms |
17256 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
74 ms |
16980 KB |
Output is correct |
15 |
Correct |
53 ms |
14132 KB |
Output is correct |
16 |
Correct |
80 ms |
16920 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
79 ms |
17176 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
51 ms |
13840 KB |
Output is correct |
3 |
Correct |
61 ms |
13964 KB |
Output is correct |
4 |
Correct |
71 ms |
16884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
51 ms |
13840 KB |
Output is correct |
3 |
Correct |
61 ms |
13964 KB |
Output is correct |
4 |
Correct |
71 ms |
16884 KB |
Output is correct |
5 |
Correct |
74 ms |
16916 KB |
Output is correct |
6 |
Correct |
72 ms |
16920 KB |
Output is correct |
7 |
Correct |
72 ms |
16920 KB |
Output is correct |
8 |
Correct |
69 ms |
16920 KB |
Output is correct |
9 |
Correct |
51 ms |
13872 KB |
Output is correct |
10 |
Correct |
71 ms |
16916 KB |
Output is correct |
11 |
Correct |
71 ms |
16916 KB |
Output is correct |
12 |
Correct |
51 ms |
13872 KB |
Output is correct |
13 |
Correct |
62 ms |
13868 KB |
Output is correct |
14 |
Correct |
52 ms |
13872 KB |
Output is correct |
15 |
Correct |
53 ms |
13872 KB |
Output is correct |
16 |
Correct |
2 ms |
732 KB |
Output is correct |
17 |
Correct |
43 ms |
9036 KB |
Output is correct |
18 |
Correct |
54 ms |
13876 KB |
Output is correct |
19 |
Correct |
54 ms |
13876 KB |
Output is correct |
20 |
Correct |
70 ms |
16924 KB |
Output is correct |
21 |
Correct |
72 ms |
16920 KB |
Output is correct |
22 |
Correct |
72 ms |
16784 KB |
Output is correct |