Submission #1041651

# Submission time Handle Problem Language Result Execution time Memory
1041651 2024-08-02T06:45:33 Z yanb Mechanical Doll (IOI18_doll) C++14
53 / 100
64 ms 13368 KB
#include <bits/stdc++.h>

using namespace std;
    
//#define int long long
//#define pii pair<long long, long long>

void answer(vector<signed> C, vector<signed> X, vector<signed> Y);

void create_circuit(int k, vector<int> a) {
	int n = a.size();
	a.push_back(0);
	vector<vector<int>> g(k + 1);
	g[0].push_back(a[0]);
	for (int i = 0; i < n; i++) {
		g[a[i]].push_back(a[i + 1]);
	}

	vector<int> C(k + 1), X, Y;
	C[0] = g[0][0];
	for (int j = 1; j < k + 1; j++) {
		int cnt = g[j].size();
		int z = 1, ord = 0;
		while (z < cnt) {
			z *= 2;
			ord++;
		}

		if (ord == 0) {
			if (cnt == 1) C[j] = g[j][0];
			continue;
		}

		vector<int> p(z);
		p[0] = 0;
		for (int i = 0; i < ord; i++) {
			for (int ni = 0; ni < (1 << i); ni++) {
				p[(1 << i) + ni] = p[ni] + (1 << (ord - i - 1));
			}
		}

		int wnots = X.size();
		C[j] = -wnots - 1;

		vector<int> v(z, -wnots - 1);
		for (int i = z - (int) g[j].size(); i < z; i++) {
			v[i] = g[j][i - z + (int) g[j].size()];
		}

		vector<int> vp(z);
		for (int i = 0; i < z; i++) {
			vp[p[i]] = v[i];
		}

		vector<int> X_(z), Y_(z);
		for (int ni = 1; ni < z / 2; ni++) {
			X_[ni] = -ni * 2 - wnots;
			Y_[ni] = -ni * 2 - 1 - wnots;
		}
		for (int ni = 0; ni < z / 2; ni++) {
			X_[ni + z / 2] = vp[ni * 2];
			Y_[ni + z / 2] = vp[ni * 2 + 1];
		}

		for (int i = 1; i < z; i++) {
			X.push_back(X_[i]);
			Y.push_back(Y_[i]);
		}
	}

	answer(C, X, Y);
}

#ifdef ONLINE_JUDGE
void answer(vector<signed> C, vector<signed> X, vector<signed> Y) {
	for (int x : C) cout << x << " ";
	cout << "\n";
	for (int x : X) cout << x << " ";
	cout << "\n";
	for (int x : Y) cout << x << " ";
	cout << "\n";
}

int main() {
	create_circuit(4, {1, 1, 1, 1, 1, 1});
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 15 ms 6484 KB Output is correct
3 Correct 11 ms 5304 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 18 ms 7636 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 15 ms 6484 KB Output is correct
3 Correct 11 ms 5304 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 18 ms 7636 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 28 ms 7256 KB Output is correct
9 Correct 26 ms 8636 KB Output is correct
10 Correct 45 ms 11332 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 15 ms 6484 KB Output is correct
3 Correct 11 ms 5304 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 6 ms 3932 KB Output is correct
6 Correct 18 ms 7636 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 28 ms 7256 KB Output is correct
9 Correct 26 ms 8636 KB Output is correct
10 Correct 45 ms 11332 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 49 ms 10992 KB Output is correct
15 Correct 25 ms 6216 KB Output is correct
16 Correct 45 ms 8772 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 48 ms 10732 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Output is partially correct
2 Correct 20 ms 6232 KB Output is correct
3 Partially correct 40 ms 9436 KB Output is partially correct
4 Partially correct 38 ms 11336 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 348 KB Output is partially correct
2 Correct 20 ms 6232 KB Output is correct
3 Partially correct 40 ms 9436 KB Output is partially correct
4 Partially correct 38 ms 11336 KB Output is partially correct
5 Partially correct 55 ms 12084 KB Output is partially correct
6 Partially correct 54 ms 13368 KB Output is partially correct
7 Partially correct 64 ms 12448 KB Output is partially correct
8 Partially correct 54 ms 12908 KB Output is partially correct
9 Partially correct 31 ms 9556 KB Output is partially correct
10 Partially correct 57 ms 13368 KB Output is partially correct
11 Partially correct 54 ms 13120 KB Output is partially correct
12 Partially correct 35 ms 8828 KB Output is partially correct
13 Partially correct 36 ms 8320 KB Output is partially correct
14 Partially correct 34 ms 8324 KB Output is partially correct
15 Partially correct 34 ms 8064 KB Output is partially correct
16 Partially correct 1 ms 604 KB Output is partially correct
17 Partially correct 28 ms 7140 KB Output is partially correct
18 Partially correct 27 ms 7256 KB Output is partially correct
19 Partially correct 28 ms 7556 KB Output is partially correct
20 Partially correct 38 ms 10040 KB Output is partially correct
21 Partially correct 45 ms 11844 KB Output is partially correct
22 Partially correct 37 ms 9544 KB Output is partially correct