답안 #407118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
407118 2021-05-18T13:51:54 Z InternetPerson10 자동 인형 (IOI18_doll) C++14
100 / 100
119 ms 9756 KB
#include <bits/stdc++.h>
#include "doll.h"

using namespace std;

vector<int> C, X, Y, v;
vector<vector<int>> vecs;

void make_batch(int k, vector<int> d) { // Makes a batch of 2^n thingies
	for(int i = 0; i < k; i++) {
		int x = (1 << i);
		if(i < k-1) {
			int z = X.size() + x;
			for(int j = 0; j < (int)x; j++) {
				X.push_back(-(z+2*j+1));
				Y.push_back(-(z+2*j+2));
			}
		}
		else {
			int m = X.size();
			for(int j = 0; j < (int)x; j++) {
				X.push_back(0);
				Y.push_back(0);
			}
			for(int j = 0; j < (int)d.size(); j++) {
				int pl = 0;
				for(int l = 0; l < k; l++) {
					if(j & (1 << l)) pl += (1 << (k-l-1));
				}
				pl = d.size() - pl - 1;
				if(pl%2) Y[m + pl/2] = d[j];
				else X[m + pl/2] = d[j];
			}
		}
	}
	return;
}

void print() {
	for(int i = 0; i < (int)C.size(); i++) cout << C[i] << ' ';
	cout << '\n';
	for(int i = 0; i < (int)X.size(); i++) cout << X[i] << ' ';
	cout << '\n';
	for(int i = 0; i < (int)Y.size(); i++) cout << Y[i] << ' ';
	cout << '\n';
	for(int i = 0; i < (int)v.size(); i++) cout << v[i] << ' ';
	cout << '\n';
	for(int i = 0; i < (int)v.size(); i++) {
		for(int j = 0; j < (int)vecs[i].size(); j++) {
			cout << vecs[i][j] << ' ';
		}
		cout << '\n';
	}
	cout << '\n';
}

void create_circuit(int m, vector<int> a) {
	vector<int>().swap(C);
	vector<int>().swap(X);
	vector<int>().swap(Y);
	vector<int>().swap(v);
	vector<vector<int>>().swap(vecs);
	int k = 69;
	int n = a.size();
	for(int i = 0; i < 20; i++) {
		if(n & (1 << i)) {
			k = i;
		}
	}
	int p = 1;
	v.resize(k+1);
	vecs.resize(k+1);
	Y.resize(k+1);
	for(int i = 0; i <= k; i++) {
		if(i == k) X.push_back(0);
		else X.push_back(-i-2);
		if(n & (1 << (k-i))) {
			p++;
			v[i] = 1;
		}
		else v[i] = 0;
	}
	p = 0;
	for(int i = 1; i < (1 << (k+1)); i++) {
		for(int j = 0; j <= k; j++) {
			if(i & (1 << j)) {
				if(v[j]) {
					vecs[j].push_back(a[p]);
					p++;
				}
				break;
			}
		}
	}
	p = k;
	for(int i = 0; i <= k; i++) {
		if(i == k) {
			if(v[i]) Y[i] = vecs[i][0];
			else Y[i] = -1;
		}
		else if(v[i]) {
			Y[i] = (int)Y.size() * -1 - 1;
			make_batch(k-i, vecs[i]);
		}
		else Y[i] = -1;
	}
	for(int i = 0; i <= m; i++) C.push_back(-1);
	// print();
	answer(C, Y, X);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 40 ms 4240 KB Output is correct
3 Correct 50 ms 4088 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1476 KB Output is correct
6 Correct 56 ms 5192 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 40 ms 4240 KB Output is correct
3 Correct 50 ms 4088 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1476 KB Output is correct
6 Correct 56 ms 5192 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 65 ms 7220 KB Output is correct
9 Correct 65 ms 7696 KB Output is correct
10 Correct 102 ms 9756 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 40 ms 4240 KB Output is correct
3 Correct 50 ms 4088 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 12 ms 1476 KB Output is correct
6 Correct 56 ms 5192 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 65 ms 7220 KB Output is correct
9 Correct 65 ms 7696 KB Output is correct
10 Correct 102 ms 9756 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 103 ms 9008 KB Output is correct
15 Correct 70 ms 6700 KB Output is correct
16 Correct 92 ms 8588 KB Output is correct
17 Correct 1 ms 244 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 119 ms 9140 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 2 ms 204 KB Output is correct
4 Correct 2 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 61 ms 5548 KB Output is correct
3 Correct 52 ms 5576 KB Output is correct
4 Correct 86 ms 7872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 61 ms 5548 KB Output is correct
3 Correct 52 ms 5576 KB Output is correct
4 Correct 86 ms 7872 KB Output is correct
5 Correct 88 ms 8548 KB Output is correct
6 Correct 89 ms 8220 KB Output is correct
7 Correct 118 ms 8204 KB Output is correct
8 Correct 85 ms 8068 KB Output is correct
9 Correct 56 ms 5548 KB Output is correct
10 Correct 85 ms 8120 KB Output is correct
11 Correct 113 ms 7884 KB Output is correct
12 Correct 55 ms 5856 KB Output is correct
13 Correct 78 ms 6160 KB Output is correct
14 Correct 57 ms 6316 KB Output is correct
15 Correct 60 ms 6420 KB Output is correct
16 Correct 3 ms 460 KB Output is correct
17 Correct 55 ms 5044 KB Output is correct
18 Correct 54 ms 5744 KB Output is correct
19 Correct 57 ms 5772 KB Output is correct
20 Correct 94 ms 8080 KB Output is correct
21 Correct 82 ms 7944 KB Output is correct
22 Correct 101 ms 7916 KB Output is correct