답안 #769077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769077 2023-06-29T06:55:30 Z SanguineChameleon 자동 인형 (IOI18_doll) C++17
49 / 100
63 ms 10432 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] > 1) {
			sub3 = false;
			break;
		}
	}
	if (sub3) {
		C.resize(M + 1);
		C[0] = A[0];
		for (int i = 0; i < N; i++) {
			if (all_cnt[A[i]] == 1) {
				C[A[i]] = (i + 1 < N ? A[i + 1] : 0);
			}
		}
		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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3028 KB Output is correct
3 Correct 10 ms 2388 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 ms 2260 KB Output is correct
6 Correct 16 ms 3388 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3028 KB Output is correct
3 Correct 10 ms 2388 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 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 32 ms 6340 KB Output is correct
9 Incorrect 60 ms 10432 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 13 ms 3028 KB Output is correct
3 Correct 10 ms 2388 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 8 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 32 ms 6340 KB Output is correct
9 Incorrect 60 ms 10432 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 33 ms 4920 KB Output is correct
3 Partially correct 45 ms 8020 KB Output is partially correct
4 Partially correct 49 ms 8776 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct
2 Correct 33 ms 4920 KB Output is correct
3 Partially correct 45 ms 8020 KB Output is partially correct
4 Partially correct 49 ms 8776 KB Output is partially correct
5 Partially correct 55 ms 10040 KB Output is partially correct
6 Partially correct 53 ms 9704 KB Output is partially correct
7 Partially correct 54 ms 9908 KB Output is partially correct
8 Partially correct 51 ms 9412 KB Output is partially correct
9 Partially correct 45 ms 8020 KB Output is partially correct
10 Partially correct 51 ms 9328 KB Output is partially correct
11 Partially correct 62 ms 8884 KB Output is partially correct
12 Partially correct 46 ms 8312 KB Output is partially correct
13 Correct 29 ms 5284 KB Output is correct
14 Partially correct 47 ms 8880 KB Output is partially correct
15 Partially correct 47 ms 9156 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Correct 28 ms 4920 KB Output is correct
18 Correct 28 ms 4920 KB Output is correct
19 Partially correct 45 ms 8216 KB Output is partially correct
20 Partially correct 52 ms 9136 KB Output is partially correct
21 Partially correct 50 ms 8884 KB Output is partially correct
22 Partially correct 63 ms 8868 KB Output is partially correct