// Iterative segt implementation makes it easy to implement yay
#include "doll.h"
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define eb(x...) emplace_back(x)
const int inf = 1e9, N = 1 << 18;
int t[N << 1], r[N];
void create_circuit(int m, vector<int> a) {
a.eb(0); int n = a.size(), sz = 1;
while (sz < n) sz <<= 1;
rep(i, 0, sz) t[i + sz] = inf;
for (int i = 0, j = 0; i < sz; ++i) {
r[i] = r[i >> 1];
if (i & 1) r[i] |= sz;
r[i] >>= 1;
if (sz - n <= r[i])
t[r[i] + sz] = a[j++];
}
int rt = 0;
vector<int> x, y;
for (int i = sz; --i; )
if (t[i << 1|0] != t[i << 1|1]) {
t[i] = --rt;
x.eb(t[i << 1|0]);
y.eb(t[i << 1|1]);
} else t[i] = t[i << 1];
rep(i, 0, -rt) {
if (x[i] == inf) x[i] = rt;
if (y[i] == inf) y[i] = rt;
}
answer(vector<int>(m + 1, rt), x, y);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
37 ms |
5544 KB |
Output is correct |
3 |
Correct |
32 ms |
5356 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1100 KB |
Output is correct |
6 |
Correct |
50 ms |
7180 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 |
37 ms |
5544 KB |
Output is correct |
3 |
Correct |
32 ms |
5356 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1100 KB |
Output is correct |
6 |
Correct |
50 ms |
7180 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
55 ms |
8656 KB |
Output is correct |
9 |
Correct |
59 ms |
9152 KB |
Output is correct |
10 |
Correct |
82 ms |
11452 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 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 |
37 ms |
5544 KB |
Output is correct |
3 |
Correct |
32 ms |
5356 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
12 ms |
1100 KB |
Output is correct |
6 |
Correct |
50 ms |
7180 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
55 ms |
8656 KB |
Output is correct |
9 |
Correct |
59 ms |
9152 KB |
Output is correct |
10 |
Correct |
82 ms |
11452 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
2 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
96 ms |
11024 KB |
Output is correct |
15 |
Correct |
52 ms |
8068 KB |
Output is correct |
16 |
Correct |
78 ms |
10672 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 |
84 ms |
11120 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 |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
20 ms |
4296 KB |
Output is correct |
3 |
Correct |
39 ms |
4296 KB |
Output is correct |
4 |
Correct |
28 ms |
4920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
20 ms |
4296 KB |
Output is correct |
3 |
Correct |
39 ms |
4296 KB |
Output is correct |
4 |
Correct |
28 ms |
4920 KB |
Output is correct |
5 |
Correct |
75 ms |
10484 KB |
Output is correct |
6 |
Correct |
76 ms |
10108 KB |
Output is correct |
7 |
Correct |
74 ms |
10284 KB |
Output is correct |
8 |
Correct |
74 ms |
9936 KB |
Output is correct |
9 |
Correct |
40 ms |
7428 KB |
Output is correct |
10 |
Correct |
69 ms |
9144 KB |
Output is correct |
11 |
Correct |
69 ms |
9524 KB |
Output is correct |
12 |
Correct |
46 ms |
8636 KB |
Output is correct |
13 |
Correct |
56 ms |
7760 KB |
Output is correct |
14 |
Correct |
50 ms |
7880 KB |
Output is correct |
15 |
Correct |
50 ms |
8000 KB |
Output is correct |
16 |
Correct |
2 ms |
588 KB |
Output is correct |
17 |
Correct |
51 ms |
7192 KB |
Output is correct |
18 |
Correct |
48 ms |
8636 KB |
Output is correct |
19 |
Correct |
49 ms |
8624 KB |
Output is correct |
20 |
Correct |
72 ms |
9716 KB |
Output is correct |
21 |
Correct |
69 ms |
9556 KB |
Output is correct |
22 |
Correct |
72 ms |
9592 KB |
Output is correct |