답안 #118308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118308 2019-06-18T15:55:53 Z Sorting 자동 인형 (IOI18_doll) C++14
100 / 100
171 ms 12180 KB
#include <bits/stdc++.h>

using namespace std;

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

vector<int> C, X, Y;

const int N = 1e6 + 7;

int B[N][2], timer[N], cnt, n, m, k = 0;

int f(int s, int e){
	if(n <= s){
		return 1;
	}
	if(s == e){
		return -1;
	}

	int m = (s + e) / 2, c = ++k;

	B[c][1] = f(s, m);
	B[c][0] = f(m + 1, e);

	return c;
}

void create_circuit(int M, vector<int> A){
	for(int i = 0; i < M; i++){
		C.push_back(-1);
	}
	C.push_back(-1);

	A.push_back(0);

	n = (int)A.size();
	m = M;

	int t = 1;
	while(t < n){
		t *= 2;
	}

	f(0, t - 1);

	for(int i = 1, c = 0; c < n;){
		int &x = B[i][timer[i] & 1];
		++timer[i];

		if(x < 0){
			x = -A[c++];
			i = 1;
			continue;
		}

		i = x;
	}

	for(int i = 1; i <= k; i++){
		X.push_back(-B[i][0]);
		Y.push_back(-B[i][1]);
	}

	answer(C, X, Y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 51 ms 4980 KB Output is correct
3 Correct 47 ms 4944 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1604 KB Output is correct
6 Correct 79 ms 7068 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 51 ms 4980 KB Output is correct
3 Correct 47 ms 4944 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1604 KB Output is correct
6 Correct 79 ms 7068 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 95 ms 8032 KB Output is correct
9 Correct 100 ms 8568 KB Output is correct
10 Correct 171 ms 12180 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 51 ms 4980 KB Output is correct
3 Correct 47 ms 4944 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1604 KB Output is correct
6 Correct 79 ms 7068 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 95 ms 8032 KB Output is correct
9 Correct 100 ms 8568 KB Output is correct
10 Correct 171 ms 12180 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 154 ms 11796 KB Output is correct
15 Correct 89 ms 7524 KB Output is correct
16 Correct 139 ms 11416 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 140 ms 12080 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 84 ms 6624 KB Output is correct
3 Correct 87 ms 6580 KB Output is correct
4 Correct 139 ms 10116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 84 ms 6624 KB Output is correct
3 Correct 87 ms 6580 KB Output is correct
4 Correct 139 ms 10116 KB Output is correct
5 Correct 139 ms 11356 KB Output is correct
6 Correct 129 ms 10956 KB Output is correct
7 Correct 132 ms 11108 KB Output is correct
8 Correct 132 ms 11108 KB Output is correct
9 Correct 86 ms 6756 KB Output is correct
10 Correct 129 ms 10652 KB Output is correct
11 Correct 132 ms 10360 KB Output is correct
12 Correct 99 ms 6864 KB Output is correct
13 Correct 86 ms 7700 KB Output is correct
14 Correct 85 ms 7372 KB Output is correct
15 Correct 88 ms 7400 KB Output is correct
16 Correct 5 ms 460 KB Output is correct
17 Correct 102 ms 7208 KB Output is correct
18 Correct 83 ms 6760 KB Output is correct
19 Correct 84 ms 6888 KB Output is correct
20 Correct 144 ms 10844 KB Output is correct
21 Correct 133 ms 10356 KB Output is correct
22 Correct 132 ms 10396 KB Output is correct