Submission #769078

# Submission time Handle Problem Language Result Execution time Memory
769078 2023-06-29T06:58:40 Z SanguineChameleon Mechanical Doll (IOI18_doll) C++17
53 / 100
73 ms 10868 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> A, C, X, Y, all_cnt, cur_cnt;
int N, M, K;

void build(int id, int depth, int cur) {
	if (depth == K - 1) {
		X[id - 1] = (cur < N - 1 ? A[cur + 1] : (cur == ((1 << K) - 1) ? 0 : -1));
		cur += 1 << depth;
		Y[id - 1] = (cur < N - 1 ? A[cur + 1] : (cur == ((1 << K) - 1) ? 0 : -1));
		return;
	}
	X[id - 1] = -(id * 2);
	Y[id - 1] = -(id * 2 + 1);
	build(id * 2, depth + 1, cur);
	build(id * 2 + 1, depth + 1, cur + (1 << depth));
}

void create_circuit(int _M, vector<int> _A) {
	A = _A;
	N = A.size();
	M = _M;
	all_cnt.resize(M + 1);
	cur_cnt.resize(M + 1);
	for (int i = 0; i < N; i++) {
		all_cnt[A[i]]++;
	}
	bool sub3 = true;
	for (int i = 1; i <= M; i++) {
		if (all_cnt[i] > 2) {
			sub3 = false;
			break;
		}
	}
	if (sub3) {
		C.resize(M + 1);
		C[0] = A[0];
		int K = 0;
		for (int i = 1; i <= M; i++) {
			if (all_cnt[i] == 2) {
				K++;
				C[i] = -K;
			}
		}
		X.resize(K);
		Y.resize(K);
		for (int i = 0; i < N; i++) {
			cur_cnt[A[i]]++;
			int nxt = (i + 1 < N ? A[i + 1] : 0);
			if (all_cnt[A[i]] == 1) {
				C[A[i]] = nxt;
			}
			if (all_cnt[A[i]] == 2) {
				if (cur_cnt[A[i]] == 1) {
					X[-C[A[i]] - 1] = nxt;
				}
				else {
					Y[-C[A[i]] - 1] = nxt;
				}
			}
		}
		answer(C, X, Y);
		return;
	}
	K = 0;
	while ((1 << K) < N) {
		K++;
	}
	C.resize(M + 1, -1);
	C[0] = A[0];
	if (K == 0) {
		answer(C, X, Y);
		return;
	}
	X.resize((1 << K) - 1);
	Y.resize((1 << K) - 1);
	build(1, 0, 0);
	answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3036 KB Output is correct
3 Correct 11 ms 2388 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 2260 KB Output is correct
6 Correct 16 ms 3388 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3036 KB Output is correct
3 Correct 11 ms 2388 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 2260 KB Output is correct
6 Correct 16 ms 3388 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 25 ms 4692 KB Output is correct
9 Correct 29 ms 4796 KB Output is correct
10 Correct 40 ms 7324 KB Output is correct
11 Correct 1 ms 284 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3036 KB Output is correct
3 Correct 11 ms 2388 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 2260 KB Output is correct
6 Correct 16 ms 3388 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 25 ms 4692 KB Output is correct
9 Correct 29 ms 4796 KB Output is correct
10 Correct 40 ms 7324 KB Output is correct
11 Correct 1 ms 284 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 73 ms 10868 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Correct 27 ms 4948 KB Output is correct
3 Partially correct 44 ms 8012 KB Output is partially correct
4 Partially correct 54 ms 8788 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Correct 27 ms 4948 KB Output is correct
3 Partially correct 44 ms 8012 KB Output is partially correct
4 Partially correct 54 ms 8788 KB Output is partially correct
5 Partially correct 56 ms 10004 KB Output is partially correct
6 Partially correct 53 ms 9652 KB Output is partially correct
7 Partially correct 53 ms 9888 KB Output is partially correct
8 Partially correct 51 ms 9432 KB Output is partially correct
9 Partially correct 44 ms 8020 KB Output is partially correct
10 Partially correct 63 ms 9268 KB Output is partially correct
11 Partially correct 51 ms 8916 KB Output is partially correct
12 Partially correct 44 ms 8256 KB Output is partially correct
13 Correct 29 ms 5300 KB Output is correct
14 Partially correct 62 ms 8864 KB Output is partially correct
15 Partially correct 49 ms 9152 KB Output is partially correct
16 Partially correct 3 ms 596 KB Output is partially correct
17 Correct 27 ms 4948 KB Output is correct
18 Correct 27 ms 4924 KB Output is correct
19 Partially correct 45 ms 8228 KB Output is partially correct
20 Partially correct 52 ms 9116 KB Output is partially correct
21 Partially correct 50 ms 8856 KB Output is partially correct
22 Partially correct 55 ms 8884 KB Output is partially correct