Submission #81977

# Submission time Handle Problem Language Result Execution time Memory
81977 2018-10-28T09:41:10 Z lovemathboy Mechanical Doll (IOI18_doll) C++14
37 / 100
132 ms 12956 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

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

int n, m;
vector<int> a, b;
vector<int> x, y;

void build(int p, int l, int r) {
	if (l == r-1) {
		if (b[l] < n) {
			x[p-1] = a[b[l]];
		}
		else x[p-1] = -1;
		if (b[r] < n) {
			y[p-1] = a[b[r]];
		}
		else if (b[r] == b.size() - 1) y[p-1] = 0;
		else y[p-1] = -1;
	}
	else {
		x[p-1] = -(2*p);
		y[p-1] = -(2*p+1);
		int mid = (l+r)/2;
		build(2*p, l, mid);
		build(2*p+1, mid+1, r);
	}
}

void create_circuit(int M, vector<int> A) {
	a = A; m = M;
	n = A.size();
	b.push_back(0);
	a.push_back(0);
	while (b.size() < n+1) {
		vector<int> temp;
		for (int i = 0; i < b.size(); i++) {
			temp.push_back(b[i]);
			temp.push_back(b[i] + b.size());
		}
		b = temp;
	}
	/*for (int i = 0; i < b.size(); i++) {
		printf("%d ", b[i]);
	}
	printf("\n");
	for (int i = 0; i < a.size(); i++) {
		printf("%d ", a[i]);
	}
	printf("\n");*/
	vector<int> C(M + 1);
	for (int i = 0; i <= m; i++) {
		C[i] = -1;
	}
	x.resize(b.size()-1); y.resize(b.size()-1);
	build(1, 0, b.size()-1);
	answer(C, x, y);
}

Compilation message

doll.cpp: In function 'void build(int, int, int)':
doll.cpp:20:17: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   else if (b[r] == b.size() - 1) y[p-1] = 0;
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:37:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |  while (b.size() < n+1) {
      |         ~~~~~~~~~^~~~~
doll.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int i = 0; i < b.size(); i++) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 328 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 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 76 ms 11544 KB Output is partially correct
3 Partially correct 75 ms 11628 KB Output is partially correct
4 Partially correct 82 ms 12044 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Partially correct 76 ms 11544 KB Output is partially correct
3 Partially correct 75 ms 11628 KB Output is partially correct
4 Partially correct 82 ms 12044 KB Output is partially correct
5 Partially correct 132 ms 12956 KB Output is partially correct
6 Partially correct 91 ms 12944 KB Output is partially correct
7 Partially correct 94 ms 12944 KB Output is partially correct
8 Partially correct 98 ms 12680 KB Output is partially correct
9 Partially correct 75 ms 11600 KB Output is partially correct
10 Partially correct 90 ms 12636 KB Output is partially correct
11 Partially correct 95 ms 12416 KB Output is partially correct
12 Partially correct 76 ms 11836 KB Output is partially correct
13 Partially correct 77 ms 12056 KB Output is partially correct
14 Partially correct 109 ms 12156 KB Output is partially correct
15 Partially correct 103 ms 12180 KB Output is partially correct
16 Partially correct 4 ms 588 KB Output is partially correct
17 Correct 46 ms 6352 KB Output is correct
18 Partially correct 78 ms 11880 KB Output is partially correct
19 Partially correct 86 ms 11796 KB Output is partially correct
20 Partially correct 88 ms 12716 KB Output is partially correct
21 Partially correct 89 ms 12436 KB Output is partially correct
22 Partially correct 114 ms 12572 KB Output is partially correct