#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
const int N = 1 << 18;
const int inf = 1e9;
int n, m, sz, lg;
int a[N];
int rev[N];
int id[N];
vector<int> x, y;
int go(int l, int r) {
if (l == r) {
if (l >= sz - n) {
return a[id[l]];
} else {
return inf;
}
} else {
int md = (l + r) >> 1;
int lv = go(l, md);
int rv = go(md + 1, r);
if (lv == inf && rv == inf) {
return inf;
} else {
x.push_back(lv);
y.push_back(rv);
return -(int) x.size();
}
}
}
void create_circuit(int m, vector<int> a) {
n = a.size();
::m = m;
for (int i = 0; i < n; ++i) {
::a[i] = a[i];
}
sz = 1, lg = 0;
while (sz < n) {
sz <<= 1;
++lg;
}
for (int i = 0; i < sz; ++i) {
for (int j = 0; j < lg; ++j) {
if (i & (1 << j)) {
rev[i] |= 1 << (lg - 1 - j);
}
}
}
int tot = 0;
for (int i = 0; i < sz; ++i) {
if (rev[i] >= sz - n) {
id[rev[i]] = ++tot;
}
}
int rt = go(0, sz - 1);
vector<int> c(m + 1, rt);
c[0] = a[0];
for (int i = 0; i < -rt; ++i) {
if (x[i] == inf) {
x[i] = rt;
}
if (y[i] == inf) {
y[i] = rt;
}
}
answer(c, x, y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
54 ms |
4504 KB |
Output is correct |
3 |
Correct |
39 ms |
5172 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
57 ms |
6256 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
54 ms |
4504 KB |
Output is correct |
3 |
Correct |
39 ms |
5172 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
57 ms |
6256 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
64 ms |
7340 KB |
Output is correct |
9 |
Correct |
87 ms |
9720 KB |
Output is correct |
10 |
Correct |
101 ms |
11384 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
54 ms |
4504 KB |
Output is correct |
3 |
Correct |
39 ms |
5172 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1484 KB |
Output is correct |
6 |
Correct |
57 ms |
6256 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
64 ms |
7340 KB |
Output is correct |
9 |
Correct |
87 ms |
9720 KB |
Output is correct |
10 |
Correct |
101 ms |
11384 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
100 ms |
10748 KB |
Output is correct |
15 |
Correct |
74 ms |
8284 KB |
Output is correct |
16 |
Correct |
98 ms |
10400 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
98 ms |
10996 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
54 ms |
6184 KB |
Output is correct |
3 |
Correct |
117 ms |
7104 KB |
Output is correct |
4 |
Correct |
93 ms |
9252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
54 ms |
6184 KB |
Output is correct |
3 |
Correct |
117 ms |
7104 KB |
Output is correct |
4 |
Correct |
93 ms |
9252 KB |
Output is correct |
5 |
Correct |
100 ms |
10144 KB |
Output is correct |
6 |
Correct |
97 ms |
9812 KB |
Output is correct |
7 |
Correct |
97 ms |
9888 KB |
Output is correct |
8 |
Correct |
100 ms |
9636 KB |
Output is correct |
9 |
Correct |
64 ms |
7040 KB |
Output is correct |
10 |
Correct |
99 ms |
9472 KB |
Output is correct |
11 |
Correct |
93 ms |
9332 KB |
Output is correct |
12 |
Correct |
67 ms |
7340 KB |
Output is correct |
13 |
Correct |
67 ms |
6268 KB |
Output is correct |
14 |
Correct |
71 ms |
7932 KB |
Output is correct |
15 |
Correct |
77 ms |
8032 KB |
Output is correct |
16 |
Correct |
3 ms |
460 KB |
Output is correct |
17 |
Correct |
59 ms |
6180 KB |
Output is correct |
18 |
Correct |
61 ms |
6176 KB |
Output is correct |
19 |
Correct |
68 ms |
7340 KB |
Output is correct |
20 |
Correct |
93 ms |
9464 KB |
Output is correct |
21 |
Correct |
100 ms |
9264 KB |
Output is correct |
22 |
Correct |
92 ms |
9308 KB |
Output is correct |