#include "doll.h"
#include "bits/stdc++.h"
#define pb(x) push_back(x)
using namespace std;
const int N = 2e5+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 |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
22 ms |
9184 KB |
Output is correct |
3 |
Correct |
17 ms |
8788 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
11 ms |
6100 KB |
Output is correct |
6 |
Correct |
33 ms |
10756 KB |
Output is correct |
7 |
Correct |
3 ms |
4972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
22 ms |
9184 KB |
Output is correct |
3 |
Correct |
17 ms |
8788 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
11 ms |
6100 KB |
Output is correct |
6 |
Correct |
33 ms |
10756 KB |
Output is correct |
7 |
Correct |
3 ms |
4972 KB |
Output is correct |
8 |
Correct |
34 ms |
11344 KB |
Output is correct |
9 |
Correct |
38 ms |
11856 KB |
Output is correct |
10 |
Correct |
68 ms |
14784 KB |
Output is correct |
11 |
Correct |
2 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4956 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
22 ms |
9184 KB |
Output is correct |
3 |
Correct |
17 ms |
8788 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
11 ms |
6100 KB |
Output is correct |
6 |
Correct |
33 ms |
10756 KB |
Output is correct |
7 |
Correct |
3 ms |
4972 KB |
Output is correct |
8 |
Correct |
34 ms |
11344 KB |
Output is correct |
9 |
Correct |
38 ms |
11856 KB |
Output is correct |
10 |
Correct |
68 ms |
14784 KB |
Output is correct |
11 |
Correct |
2 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4956 KB |
Output is correct |
13 |
Correct |
3 ms |
4948 KB |
Output is correct |
14 |
Correct |
83 ms |
16108 KB |
Output is correct |
15 |
Correct |
36 ms |
10748 KB |
Output is correct |
16 |
Correct |
55 ms |
13716 KB |
Output is correct |
17 |
Correct |
3 ms |
5004 KB |
Output is correct |
18 |
Correct |
3 ms |
4988 KB |
Output is correct |
19 |
Correct |
2 ms |
5000 KB |
Output is correct |
20 |
Correct |
58 ms |
15120 KB |
Output is correct |
21 |
Correct |
2 ms |
4948 KB |
Output is correct |
22 |
Correct |
3 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
4948 KB |
Output is partially correct |
2 |
Correct |
40 ms |
11840 KB |
Output is correct |
3 |
Runtime error |
46 ms |
19944 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
4948 KB |
Output is partially correct |
2 |
Correct |
40 ms |
11840 KB |
Output is correct |
3 |
Runtime error |
46 ms |
19944 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |