Submission #102078

# Submission time Handle Problem Language Result Execution time Memory
102078 2019-03-22T07:02:14 Z bert30702 Mechanical Doll (IOI18_doll) C++17
47 / 100
195 ms 11952 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 << 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(ptr != 0 and *max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end())) 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) {
	vector<int> a(v.begin() + 1, v.end()); a.push_back(0);
	int k = max(2, 1 << __lg(a.size() * 2 - 1));
	vector<int> tmp(k), GG(k, 0);
	int need = k - a.size();
	for(int i = 0; i <     need; i ++) tmp[i] = -1;
	for(int i = 0; i < a.size(); i ++) tmp[i + need] = a[i];
//	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();
//	}
	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(100000, {44135, 56348, 19047, 45933, 82429, 97231, 20613, 10472, 34398, 72594, 60486, 14499, 13048, 53662, 38600, 74603});
//}

Compilation message

doll.cpp: In function 'int build(std::vector<int>)':
doll.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0; i < v.size(); i ++) {
      |                 ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < a.size(); i ++) tmp[i + need] = a[i];
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 24 ms 4916 KB Output is correct
3 Partially correct 154 ms 11048 KB Output is partially correct
4 Correct 146 ms 10316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 24 ms 4916 KB Output is correct
3 Partially correct 154 ms 11048 KB Output is partially correct
4 Correct 146 ms 10316 KB Output is correct
5 Partially correct 195 ms 11936 KB Output is partially correct
6 Partially correct 165 ms 11952 KB Output is partially correct
7 Partially correct 160 ms 11880 KB Output is partially correct
8 Partially correct 162 ms 11912 KB Output is partially correct
9 Partially correct 178 ms 11048 KB Output is partially correct
10 Partially correct 160 ms 11688 KB Output is partially correct
11 Partially correct 160 ms 11820 KB Output is partially correct
12 Partially correct 162 ms 11036 KB Output is partially correct
13 Correct 85 ms 7136 KB Output is correct
14 Partially correct 156 ms 11272 KB Output is partially correct
15 Partially correct 150 ms 11264 KB Output is partially correct
16 Partially correct 5 ms 716 KB Output is partially correct
17 Correct 86 ms 6844 KB Output is correct
18 Correct 83 ms 6760 KB Output is correct
19 Partially correct 151 ms 11048 KB Output is partially correct
20 Partially correct 174 ms 11828 KB Output is partially correct
21 Partially correct 156 ms 11848 KB Output is partially correct
22 Partially correct 160 ms 11896 KB Output is partially correct