Submission #541977

# Submission time Handle Problem Language Result Execution time Memory
541977 2022-03-24T23:32:19 Z sliviu Mechanical Doll (IOI18_doll) C++17
100 / 100
123 ms 10812 KB
#include <bits/stdc++.h>
#include "doll.h"

using namespace std;

void create_circuit(int m, vector<int> a) {
	int n = a.size(), p = 1, k = 1;
	if (a.size() & 1)
		a.emplace_back(-1);
	a.emplace_back(0);
	vector<int> c(m + 1, -1), x(400001), y(400001), parity(400001);
	while (p < n)
		p *= 2;
	function<int(int, int)> Build = [&](int left, int right) {
		if (left == right)
			return 0;
		if (right < p - n)
			return -1;
		int m = (left + right) / 2, cur = k++;
		x[cur - 1] = Build(left, m), y[cur - 1] = Build(m + 1, right);
		return -cur;
	};
	Build(0, p - 1);
	for (int i = 1; i <= n + (n & 1); ++i) {
		int cur = -1;
		while (cur) {
			int& next = !parity[-cur - 1] ? x[-cur - 1] : y[-cur - 1];
			parity[-cur - 1] ^= 1;
			cur = next;
			if (!next)
				next = a[i];
		}
	}
	c[0] = a[0];
	x.resize(k), y.resize(k);
	answer(c, x, y);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 53 ms 7716 KB Output is correct
3 Correct 41 ms 7324 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 11 ms 6100 KB Output is correct
6 Correct 62 ms 8488 KB Output is correct
7 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 53 ms 7716 KB Output is correct
3 Correct 41 ms 7324 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 11 ms 6100 KB Output is correct
6 Correct 62 ms 8488 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 76 ms 8776 KB Output is correct
9 Correct 83 ms 9240 KB Output is correct
10 Correct 123 ms 10812 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 53 ms 7716 KB Output is correct
3 Correct 41 ms 7324 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 11 ms 6100 KB Output is correct
6 Correct 62 ms 8488 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 76 ms 8776 KB Output is correct
9 Correct 83 ms 9240 KB Output is correct
10 Correct 123 ms 10812 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 122 ms 10408 KB Output is correct
15 Correct 78 ms 8392 KB Output is correct
16 Correct 120 ms 10248 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 119 ms 10584 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 3 ms 4964 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 71 ms 8080 KB Output is correct
3 Correct 86 ms 8008 KB Output is correct
4 Correct 110 ms 9644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 71 ms 8080 KB Output is correct
3 Correct 86 ms 8008 KB Output is correct
4 Correct 110 ms 9644 KB Output is correct
5 Correct 119 ms 10048 KB Output is correct
6 Correct 116 ms 9904 KB Output is correct
7 Correct 117 ms 10000 KB Output is correct
8 Correct 113 ms 9808 KB Output is correct
9 Correct 76 ms 8008 KB Output is correct
10 Correct 113 ms 9656 KB Output is correct
11 Correct 111 ms 9636 KB Output is correct
12 Correct 74 ms 7960 KB Output is correct
13 Correct 72 ms 8132 KB Output is correct
14 Correct 79 ms 8264 KB Output is correct
15 Correct 78 ms 8372 KB Output is correct
16 Correct 4 ms 5076 KB Output is correct
17 Correct 71 ms 7964 KB Output is correct
18 Correct 73 ms 8072 KB Output is correct
19 Correct 77 ms 8052 KB Output is correct
20 Correct 110 ms 9656 KB Output is correct
21 Correct 119 ms 9648 KB Output is correct
22 Correct 116 ms 9648 KB Output is correct