Submission #231081

# Submission time Handle Problem Language Result Execution time Memory
231081 2020-05-12T15:45:52 Z islingr Mechanical Doll (IOI18_doll) C++14
100 / 100
89 ms 11508 KB
// Iterative segtree 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);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 40 ms 5444 KB Output is correct
3 Correct 46 ms 5328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1220 KB Output is correct
6 Correct 48 ms 7064 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 40 ms 5444 KB Output is correct
3 Correct 46 ms 5328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1220 KB Output is correct
6 Correct 48 ms 7064 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 59 ms 8632 KB Output is correct
9 Correct 80 ms 9128 KB Output is correct
10 Correct 83 ms 11508 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 40 ms 5444 KB Output is correct
3 Correct 46 ms 5328 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1220 KB Output is correct
6 Correct 48 ms 7064 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 59 ms 8632 KB Output is correct
9 Correct 80 ms 9128 KB Output is correct
10 Correct 83 ms 11508 KB Output is correct
11 Correct 2 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 84 ms 10952 KB Output is correct
15 Correct 66 ms 8072 KB Output is correct
16 Correct 81 ms 10728 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 82 ms 11128 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 24 ms 4404 KB Output is correct
3 Correct 22 ms 4296 KB Output is correct
4 Correct 44 ms 4904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 24 ms 4404 KB Output is correct
3 Correct 22 ms 4296 KB Output is correct
4 Correct 44 ms 4904 KB Output is correct
5 Correct 83 ms 10480 KB Output is correct
6 Correct 89 ms 10168 KB Output is correct
7 Correct 85 ms 10236 KB Output is correct
8 Correct 76 ms 9976 KB Output is correct
9 Correct 42 ms 7356 KB Output is correct
10 Correct 78 ms 9192 KB Output is correct
11 Correct 85 ms 9512 KB Output is correct
12 Correct 52 ms 8728 KB Output is correct
13 Correct 55 ms 7724 KB Output is correct
14 Correct 53 ms 7768 KB Output is correct
15 Correct 57 ms 8012 KB Output is correct
16 Correct 3 ms 588 KB Output is correct
17 Correct 49 ms 7160 KB Output is correct
18 Correct 50 ms 8672 KB Output is correct
19 Correct 54 ms 8676 KB Output is correct
20 Correct 80 ms 9760 KB Output is correct
21 Correct 82 ms 9524 KB Output is correct
22 Correct 80 ms 9580 KB Output is correct