#include "doll.h"
#include "bits/stdc++.h"
#define pb(x) push_back(x)
using namespace std;
const int N = 4e5+5;
vector<int> X, Y;
vector<int> adj[N];
int who[N], sw[N], S;
void f(int nd, int pos, int pw, int id){
if (!pw){
who[pos] = id;
return;
}
sw[nd] ^= 1;
if (sw[nd])
f(nd*2, pos, pw/2, id);
else
f(nd*2+1, pos+pw, pw/2, id);
}
int get_switch(){
return --S;
}
int get_root(vector<int> &values){
int sz = values.size();
if (sz == 0)
return 0;
if (sz == 1)
return values[0];
int pw = 1;
while (pw < sz) pw *= 2;
for (int i = 0; i < pw; i++)
f(1, 0, pw/2, i);
int root = get_switch();
int to_the_root = pw - sz;
for (int i = 1; i < pw / 2; i++){
X.push_back(get_switch());
Y.push_back(get_switch());
}
for (int i = 0; i < pw / 2; i++){
int l = i * 2;
int r = i * 2 + 1;
if (who[l] < to_the_root) X.push_back(root);
else X.push_back(values[who[l] - to_the_root]);
if (who[r] < to_the_root) Y.push_back(root);
else Y.push_back(values[who[r] - to_the_root]);
}
return root;
}
void create_circuit(int M, vector<int> A) {
int N = A.size();
adj[0].pb(A[0]);
for (int i = 0; i < N - 1; i++)
adj[A[i]].pb(A[i+1]);
adj[A[N-1]].pb(0);
vector<int> C(M + 1);
for (int i = 0; i <= M; ++i)
C[i] = get_root(adj[i]);
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
23 ms |
13396 KB |
Output is correct |
3 |
Correct |
22 ms |
13044 KB |
Output is correct |
4 |
Correct |
4 ms |
9684 KB |
Output is correct |
5 |
Correct |
13 ms |
10836 KB |
Output is correct |
6 |
Correct |
28 ms |
14804 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
23 ms |
13396 KB |
Output is correct |
3 |
Correct |
22 ms |
13044 KB |
Output is correct |
4 |
Correct |
4 ms |
9684 KB |
Output is correct |
5 |
Correct |
13 ms |
10836 KB |
Output is correct |
6 |
Correct |
28 ms |
14804 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
40 ms |
15100 KB |
Output is correct |
9 |
Correct |
39 ms |
15696 KB |
Output is correct |
10 |
Correct |
54 ms |
18104 KB |
Output is correct |
11 |
Correct |
6 ms |
9684 KB |
Output is correct |
12 |
Correct |
5 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9684 KB |
Output is correct |
2 |
Correct |
23 ms |
13396 KB |
Output is correct |
3 |
Correct |
22 ms |
13044 KB |
Output is correct |
4 |
Correct |
4 ms |
9684 KB |
Output is correct |
5 |
Correct |
13 ms |
10836 KB |
Output is correct |
6 |
Correct |
28 ms |
14804 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
40 ms |
15100 KB |
Output is correct |
9 |
Correct |
39 ms |
15696 KB |
Output is correct |
10 |
Correct |
54 ms |
18104 KB |
Output is correct |
11 |
Correct |
6 ms |
9684 KB |
Output is correct |
12 |
Correct |
5 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
14 |
Correct |
68 ms |
19356 KB |
Output is correct |
15 |
Correct |
37 ms |
14532 KB |
Output is correct |
16 |
Correct |
57 ms |
17012 KB |
Output is correct |
17 |
Correct |
5 ms |
9684 KB |
Output is correct |
18 |
Correct |
4 ms |
9684 KB |
Output is correct |
19 |
Correct |
4 ms |
9684 KB |
Output is correct |
20 |
Correct |
62 ms |
18380 KB |
Output is correct |
21 |
Correct |
6 ms |
9684 KB |
Output is correct |
22 |
Correct |
6 ms |
9684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
9684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
9684 KB |
Output is partially correct |
2 |
Correct |
56 ms |
15612 KB |
Output is correct |
3 |
Partially correct |
76 ms |
19712 KB |
Output is partially correct |
4 |
Partially correct |
79 ms |
21868 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
9684 KB |
Output is partially correct |
2 |
Correct |
56 ms |
15612 KB |
Output is correct |
3 |
Partially correct |
76 ms |
19712 KB |
Output is partially correct |
4 |
Partially correct |
79 ms |
21868 KB |
Output is partially correct |
5 |
Partially correct |
80 ms |
23016 KB |
Output is partially correct |
6 |
Partially correct |
89 ms |
24312 KB |
Output is partially correct |
7 |
Partially correct |
82 ms |
23928 KB |
Output is partially correct |
8 |
Partially correct |
90 ms |
24948 KB |
Output is partially correct |
9 |
Partially correct |
72 ms |
20644 KB |
Output is partially correct |
10 |
Partially correct |
98 ms |
26268 KB |
Output is partially correct |
11 |
Partially correct |
97 ms |
25468 KB |
Output is partially correct |
12 |
Partially correct |
64 ms |
20100 KB |
Output is partially correct |
13 |
Partially correct |
56 ms |
19436 KB |
Output is partially correct |
14 |
Partially correct |
54 ms |
18924 KB |
Output is partially correct |
15 |
Partially correct |
58 ms |
18456 KB |
Output is partially correct |
16 |
Partially correct |
6 ms |
9940 KB |
Output is partially correct |
17 |
Partially correct |
49 ms |
17812 KB |
Output is partially correct |
18 |
Partially correct |
53 ms |
17780 KB |
Output is partially correct |
19 |
Partially correct |
52 ms |
18412 KB |
Output is partially correct |
20 |
Partially correct |
66 ms |
21136 KB |
Output is partially correct |
21 |
Partially correct |
90 ms |
23500 KB |
Output is partially correct |
22 |
Partially correct |
62 ms |
20448 KB |
Output is partially correct |