#include "doll.h"
#include <bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int(x.size()))
using namespace std;
void create_circuit(int m, vector<int> a){
int n = a.size();
int N = 1;
while(N <= n) N <<= 1;
int pierwszy = N-n-1;
vector<int> perm(N, 0);
FOR(i, 1, N-1) perm[i] = (perm[i>>1]>>1) + (i&1 ? (N>>1) : 0);
int iter = 0;
vector<int> tab(N);
REP(i, N) if(pierwszy <= perm[i] && perm[i] < N-1) tab[perm[i]] = a[iter++];
int it = 0;
vector<int> x, y;
auto nowy = [&](){
x.emplace_back(0);
y.emplace_back(0);
++it;
};
function<void(int, int, int)> dfs = [&](int w, int lewo, int prawo){
int sr = (lewo+prawo)>>1;
//printf("w: %d\n", w);
if(sr < pierwszy){
x[-w-1] = -1;
}
else{
if(lewo == sr){
x[-w-1] = tab[lewo];
}
else{
nowy();
x[-w-1] = -it;
dfs(-it, lewo, sr);
}
}
if(sr+1 == prawo){
if(prawo == N-1) y[-w-1] = 0;
else y[-w-1] = tab[prawo];
}
else{
nowy();
y[-w-1] = -it;
dfs(-it, sr+1, prawo);
}
};
nowy();
dfs(-1, 0, N-1);
vector<int> c(m+1, -1);
/*printf("c: ");
for(int i : c) printf("%d ", i);
printf("\n");
printf("x: ");
for(int i : x) printf("%d ", i);
printf("\n");
printf("y: ");
for(int i : y) printf("%d ", i);
printf("\n");*/
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
24 ms |
5036 KB |
Output is correct |
3 |
Correct |
21 ms |
4560 KB |
Output is correct |
4 |
Correct |
1 ms |
352 KB |
Output is correct |
5 |
Correct |
9 ms |
1632 KB |
Output is correct |
6 |
Correct |
32 ms |
6360 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
24 ms |
5036 KB |
Output is correct |
3 |
Correct |
21 ms |
4560 KB |
Output is correct |
4 |
Correct |
1 ms |
352 KB |
Output is correct |
5 |
Correct |
9 ms |
1632 KB |
Output is correct |
6 |
Correct |
32 ms |
6360 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
38 ms |
7992 KB |
Output is correct |
9 |
Correct |
40 ms |
8392 KB |
Output is correct |
10 |
Correct |
63 ms |
10956 KB |
Output is correct |
11 |
Correct |
0 ms |
352 KB |
Output is correct |
12 |
Correct |
0 ms |
356 KB |
Output is correct |
13 |
Correct |
0 ms |
356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
24 ms |
5036 KB |
Output is correct |
3 |
Correct |
21 ms |
4560 KB |
Output is correct |
4 |
Correct |
1 ms |
352 KB |
Output is correct |
5 |
Correct |
9 ms |
1632 KB |
Output is correct |
6 |
Correct |
32 ms |
6360 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
38 ms |
7992 KB |
Output is correct |
9 |
Correct |
40 ms |
8392 KB |
Output is correct |
10 |
Correct |
63 ms |
10956 KB |
Output is correct |
11 |
Correct |
0 ms |
352 KB |
Output is correct |
12 |
Correct |
0 ms |
356 KB |
Output is correct |
13 |
Correct |
0 ms |
356 KB |
Output is correct |
14 |
Correct |
54 ms |
10444 KB |
Output is correct |
15 |
Correct |
36 ms |
7628 KB |
Output is correct |
16 |
Correct |
52 ms |
10580 KB |
Output is correct |
17 |
Correct |
0 ms |
352 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
56 ms |
10660 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
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 |
1 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 |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
7200 KB |
Output is correct |
3 |
Correct |
33 ms |
7164 KB |
Output is correct |
4 |
Correct |
47 ms |
9880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
32 ms |
7200 KB |
Output is correct |
3 |
Correct |
33 ms |
7164 KB |
Output is correct |
4 |
Correct |
47 ms |
9880 KB |
Output is correct |
5 |
Correct |
53 ms |
10172 KB |
Output is correct |
6 |
Correct |
53 ms |
10024 KB |
Output is correct |
7 |
Correct |
55 ms |
9916 KB |
Output is correct |
8 |
Correct |
65 ms |
9920 KB |
Output is correct |
9 |
Correct |
31 ms |
7364 KB |
Output is correct |
10 |
Correct |
48 ms |
9928 KB |
Output is correct |
11 |
Correct |
52 ms |
9776 KB |
Output is correct |
12 |
Correct |
32 ms |
7356 KB |
Output is correct |
13 |
Correct |
33 ms |
7468 KB |
Output is correct |
14 |
Correct |
34 ms |
7516 KB |
Output is correct |
15 |
Correct |
34 ms |
7468 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
32 ms |
6352 KB |
Output is correct |
18 |
Correct |
35 ms |
7368 KB |
Output is correct |
19 |
Correct |
32 ms |
7368 KB |
Output is correct |
20 |
Correct |
48 ms |
9776 KB |
Output is correct |
21 |
Correct |
49 ms |
9840 KB |
Output is correct |
22 |
Correct |
49 ms |
9928 KB |
Output is correct |