답안 #1010412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010412 2024-06-29T05:26:03 Z 정민찬(#10827) 자동 인형 (IOI18_doll) C++17
100 / 100
112 ms 11944 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);

int pv;
vector<int> X, Y;

int make_tree(int s, int e, int k) {
	if (e <= k) return -1;
	if (s == e) return 0;
	int node = ++ pv;
	X.push_back(0); Y.push_back(0);
	int mid = s + e >> 1;
	X[node-1] = make_tree(s, mid, k);
	Y[node-1] = make_tree(mid+1, e, k);
	return -node;
}

vector<int> cond;

bool update(int node, int val) {
	if (cond[node-1] == 0) {
		cond[node-1] = 1;
		if (X[node-1] == 0) {
			X[node-1] = val;
			return true;
		}
		if (X[node-1] == -1) return false;
		return update(-X[node-1], val);
	}
	else {
		cond[node-1] = 0;
		if (Y[node-1] == 0) {
			Y[node-1] = val;
			return true;
		}
		if (Y[node-1] == -1) return false;
		return update(-Y[node-1], val);
	}
}

void create_circuit(int M, vector<int> A) {
	vector<int> C(M+1, -1);
	A.insert(A.begin(), 0);
	A.push_back(0);
	int N = A.size() - 1;
	int pw = 1;
	while (pw < N) pw *= 2;
	make_tree(1, pw, pw - N);
	cond.assign(pw, 0);
	for (int i=1; i<=N; i++) {
		while (!update(1, A[i])) {

		}
	}
	answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'int make_tree(int, int, int)':
doll.cpp:16:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   16 |  int mid = s + e >> 1;
      |            ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 29 ms 4932 KB Output is correct
3 Correct 44 ms 4944 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 11 ms 1372 KB Output is correct
6 Correct 49 ms 6740 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 29 ms 4932 KB Output is correct
3 Correct 44 ms 4944 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 11 ms 1372 KB Output is correct
6 Correct 49 ms 6740 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 67 ms 8308 KB Output is correct
9 Correct 88 ms 8944 KB Output is correct
10 Correct 79 ms 11944 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 29 ms 4932 KB Output is correct
3 Correct 44 ms 4944 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 11 ms 1372 KB Output is correct
6 Correct 49 ms 6740 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 67 ms 8308 KB Output is correct
9 Correct 88 ms 8944 KB Output is correct
10 Correct 79 ms 11944 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 87 ms 11560 KB Output is correct
15 Correct 62 ms 7908 KB Output is correct
16 Correct 76 ms 11376 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 600 KB Output is correct
20 Correct 84 ms 11768 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 7028 KB Output is correct
3 Correct 57 ms 7156 KB Output is correct
4 Correct 72 ms 10240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 58 ms 7028 KB Output is correct
3 Correct 57 ms 7156 KB Output is correct
4 Correct 72 ms 10240 KB Output is correct
5 Correct 87 ms 11416 KB Output is correct
6 Correct 87 ms 11080 KB Output is correct
7 Correct 88 ms 11280 KB Output is correct
8 Correct 105 ms 11060 KB Output is correct
9 Correct 63 ms 7024 KB Output is correct
10 Correct 75 ms 10804 KB Output is correct
11 Correct 96 ms 10480 KB Output is correct
12 Correct 75 ms 7284 KB Output is correct
13 Correct 58 ms 7728 KB Output is correct
14 Correct 64 ms 7792 KB Output is correct
15 Correct 56 ms 8056 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 49 ms 7232 KB Output is correct
18 Correct 55 ms 7284 KB Output is correct
19 Correct 63 ms 7284 KB Output is correct
20 Correct 112 ms 10776 KB Output is correct
21 Correct 90 ms 10512 KB Output is correct
22 Correct 78 ms 10516 KB Output is correct