답안 #102089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102089 2019-03-22T07:28:28 Z bert30702 자동 인형 (IOI18_doll) C++17
73.4718 / 100
161 ms 10548 KB
#include <bits/stdc++.h>
 #include "doll.h"
using namespace std;
const int MX = 4e5 + 1000;
int ptr = 0;
int x[MX], y[MX], c[MX];
//void answer(vector<int> c, vector<int> x, vector<int> y) {
//	cout << 9 << ' ' << x.size() << endl;
//	for(auto it: c) cout << it << ' '; cout << endl;
//	for(auto it: x) cout << it << ' '; cout << endl;
//	for(auto it: y) cout << it << ' '; cout << endl;
//}
int build(vector<int> v) {
	if(v.size() == 1) return v[0];
	if(ptr != 0 and *max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end()) and v[0] == -1) return v[0];
	int d = --ptr;
	vector<int> a, b;
	for(int i = 0; i < v.size(); i ++) {
		if(i & 1) b.push_back(v[i]);
		else      a.push_back(v[i]);
	}
	x[-d] = build(a);
	y[-d] = build(b);
	return d;
}
void create_circuit(int n, vector<int> v) {
	// for(auto it: v) cout << it << ' '; cout << endl;
	vector<int> a(v.begin() + 1, v.end()); a.push_back(0);
	// for(auto it: a) cout << it << ' '; cout << endl;
	int k = max(2, 1 << __lg(a.size() * 2 - 1));
	// cout << " ss " << k << ' ' << a.size() << endl;
	vector<int> tmp(k), GG(k, 0);
	int need = k - a.size();
	for(int i = k / 2; i >= 1; i >>= 1) {
		for(int j = 0; j < k; j += i) {
			if(!GG[j] and need) {
				GG[j] = true, tmp[j] = -1, need --;
			}
		}
	}
	for(int i = k - 1; i >= 0; i --) {
		if(!GG[i]) tmp[i] = a.back(), a.pop_back();
	}
	// for(auto it: tmp) cout << it << ' '; cout << endl;
	build(tmp); c[0] = v[0];
	for(int i = 1; i <= n; i ++) c[i] = -1;
	answer(
		vector<int>(c, c + n + 1),
		vector<int>(x + 1, x + 1 - ptr),
		vector<int>(y + 1, y + 1 - ptr)
	);
}
//main () {
//	// create_circuit(4, {1, 2, 1, 3});
//	create_circuit(1, vector<int> (33, 1));
//}

Compilation message

doll.cpp: In function 'int build(std::vector<int>)':
doll.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i = 0; i < v.size(); i ++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 56 ms 4720 KB Output is correct
3 Correct 73 ms 4688 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 18 ms 1484 KB Output is correct
6 Incorrect 82 ms 6824 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 56 ms 4720 KB Output is correct
3 Correct 73 ms 4688 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 18 ms 1484 KB Output is correct
6 Incorrect 82 ms 6824 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 56 ms 4720 KB Output is correct
3 Correct 73 ms 4688 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 18 ms 1484 KB Output is correct
6 Incorrect 82 ms 6824 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 109 ms 6564 KB Output is correct
3 Correct 95 ms 9028 KB Output is correct
4 Partially correct 138 ms 10432 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 109 ms 6564 KB Output is correct
3 Correct 95 ms 9028 KB Output is correct
4 Partially correct 138 ms 10432 KB Output is partially correct
5 Partially correct 155 ms 10376 KB Output is partially correct
6 Partially correct 159 ms 10416 KB Output is partially correct
7 Partially correct 151 ms 10388 KB Output is partially correct
8 Partially correct 150 ms 10480 KB Output is partially correct
9 Partially correct 105 ms 9012 KB Output is partially correct
10 Partially correct 161 ms 10420 KB Output is partially correct
11 Partially correct 140 ms 10480 KB Output is partially correct
12 Correct 94 ms 9052 KB Output is correct
13 Correct 87 ms 7048 KB Output is correct
14 Correct 100 ms 9008 KB Output is correct
15 Correct 101 ms 8988 KB Output is correct
16 Correct 4 ms 588 KB Output is correct
17 Correct 86 ms 6892 KB Output is correct
18 Correct 84 ms 6816 KB Output is correct
19 Correct 95 ms 9016 KB Output is correct
20 Partially correct 148 ms 10400 KB Output is partially correct
21 Partially correct 144 ms 10548 KB Output is partially correct
22 Partially correct 152 ms 10452 KB Output is partially correct