답안 #297784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
297784 2020-09-11T22:37:38 Z ChrisT 자동 인형 (IOI18_doll) C++17
100 / 100
168 ms 8412 KB
#include <bits/stdc++.h>
#include "doll.h" 
using namespace std;
void create_circuit (int m, vector<int> a) {
	a.push_back(0);
	int n = (int)a.size(), go = 1 << (__lg(n - 1) + 1), cur = 1; ++m;
	vector<int> c(m), x(1), y(1);
	iota(c.begin(),c.end(),0); c[0] = -1;
	vector<int> order;
	auto get = [&] (int l, int r, int ind, int dep, const auto &ref) -> void {
		if (l == r) {
			if (l - go + n >= 0) order.push_back(ind);
			return;
		}
		int mid = (l + r) / 2;
		ref(l,mid,ind,dep+1,ref); ref(mid+1,r,ind|(1<<dep),dep+1,ref); 
	};
	get(0,go-1,0,0,get);
	sort(order.begin(),order.end());
	auto build = [&] (int l, int r, int ind, int dep, const auto &ref) -> int {
		if (l == r) {
			if (l - go + n < 0) return -1;
			int want = lower_bound(order.begin(),order.end(),ind) - order.begin();
			c[a[want]] = -1;
			return a[want];
		}
		int mid = (l + r) / 2;
		int lc = ref(l,mid,ind,dep+1,ref), rc = ref(mid+1,r,ind | (1 << dep),dep+1,ref);
		if (lc == rc) return lc;
		x.push_back(lc); y.push_back(rc);
		return -(++cur);
	};
	x[0] = build(0,go/2-1,0,1,build); y[0] = build(go/2,go-1,1,1,build);
	answer(c,x,y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 48 ms 4036 KB Output is correct
3 Correct 43 ms 3824 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 20 ms 1356 KB Output is correct
6 Correct 86 ms 5420 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 48 ms 4036 KB Output is correct
3 Correct 43 ms 3824 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 20 ms 1356 KB Output is correct
6 Correct 86 ms 5420 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 85 ms 5584 KB Output is correct
9 Correct 93 ms 6016 KB Output is correct
10 Correct 131 ms 8412 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 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 48 ms 4036 KB Output is correct
3 Correct 43 ms 3824 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 20 ms 1356 KB Output is correct
6 Correct 86 ms 5420 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 85 ms 5584 KB Output is correct
9 Correct 93 ms 6016 KB Output is correct
10 Correct 131 ms 8412 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 130 ms 8092 KB Output is correct
15 Correct 97 ms 5228 KB Output is correct
16 Correct 135 ms 7840 KB Output is correct
17 Correct 1 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 128 ms 8200 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 204 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 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 53 ms 2856 KB Output is correct
3 Correct 47 ms 2868 KB Output is correct
4 Correct 85 ms 3664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 53 ms 2856 KB Output is correct
3 Correct 47 ms 2868 KB Output is correct
4 Correct 85 ms 3664 KB Output is correct
5 Correct 157 ms 7716 KB Output is correct
6 Correct 136 ms 7496 KB Output is correct
7 Correct 133 ms 7576 KB Output is correct
8 Correct 122 ms 7464 KB Output is correct
9 Correct 86 ms 4448 KB Output is correct
10 Correct 114 ms 6820 KB Output is correct
11 Correct 119 ms 7256 KB Output is correct
12 Correct 80 ms 5660 KB Output is correct
13 Correct 94 ms 4972 KB Output is correct
14 Correct 81 ms 5100 KB Output is correct
15 Correct 83 ms 5184 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 73 ms 6560 KB Output is correct
18 Correct 77 ms 5616 KB Output is correct
19 Correct 74 ms 5632 KB Output is correct
20 Correct 168 ms 7348 KB Output is correct
21 Correct 114 ms 7320 KB Output is correct
22 Correct 132 ms 7348 KB Output is correct