#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]);
}
answer(C, X, Y);
}
// int main() {
// create_circuit(0, vector<int>());
// }
# |
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 |
19 ms |
6372 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8304 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 |
19 ms |
6372 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8304 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
44 ms |
9216 KB |
Output is correct |
9 |
Correct |
45 ms |
9616 KB |
Output is correct |
10 |
Correct |
62 ms |
13132 KB |
Output is correct |
11 |
Correct |
1 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 |
19 ms |
6372 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
27 ms |
8304 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
44 ms |
9216 KB |
Output is correct |
9 |
Correct |
45 ms |
9616 KB |
Output is correct |
10 |
Correct |
62 ms |
13132 KB |
Output is correct |
11 |
Correct |
1 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 |
42 ms |
9028 KB |
Output is correct |
16 |
Correct |
64 ms |
12132 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 |
84 ms |
13624 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 |
32 ms |
9088 KB |
Output is correct |
3 |
Partially correct |
53 ms |
13452 KB |
Output is partially correct |
4 |
Partially correct |
62 ms |
14500 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
32 ms |
9088 KB |
Output is correct |
3 |
Partially correct |
53 ms |
13452 KB |
Output is partially correct |
4 |
Partially correct |
62 ms |
14500 KB |
Output is partially correct |
5 |
Partially correct |
89 ms |
16560 KB |
Output is partially correct |
6 |
Partially correct |
90 ms |
17920 KB |
Output is partially correct |
7 |
Partially correct |
91 ms |
17460 KB |
Output is partially correct |
8 |
Partially correct |
98 ms |
18500 KB |
Output is partially correct |
9 |
Partially correct |
64 ms |
12064 KB |
Output is partially correct |
10 |
Partially correct |
91 ms |
18820 KB |
Output is partially correct |
11 |
Partially correct |
93 ms |
19292 KB |
Output is partially correct |
12 |
Partially correct |
53 ms |
13052 KB |
Output is partially correct |
13 |
Partially correct |
59 ms |
11712 KB |
Output is partially correct |
14 |
Partially correct |
58 ms |
11400 KB |
Output is partially correct |
15 |
Partially correct |
58 ms |
11004 KB |
Output is partially correct |
16 |
Partially correct |
2 ms |
2900 KB |
Output is partially correct |
17 |
Partially correct |
44 ms |
10332 KB |
Output is partially correct |
18 |
Partially correct |
46 ms |
11308 KB |
Output is partially correct |
19 |
Partially correct |
47 ms |
11676 KB |
Output is partially correct |
20 |
Partially correct |
65 ms |
14564 KB |
Output is partially correct |
21 |
Partially correct |
73 ms |
17188 KB |
Output is partially correct |
22 |
Partially correct |
57 ms |
13832 KB |
Output is partially correct |