Submission #248544

# Submission time Handle Problem Language Result Execution time Memory
248544 2020-07-12T16:56:07 Z kostia244 Mechanical Doll (IOI18_doll) C++17
28 / 100
185 ms 10496 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
const int inf = 1<<29;
int n, m;
vector<int> x, y;
int build(vector<int> a, int S) {
	//cout << S << " " << a.size() << endl;
	if(a.empty() || a.back() == -1) return -1;
	if(S == 1) return a.back();
	x.push_back(0);
	y.push_back(0);
	int id = (int)x.size();
	int cur = 1, t = max(0, (int)a.size() - (S/2));
	vector<int> b[2];
	//for(auto i : a) cout << i << " "; cout << '\n';
	while(a.size()) {
		b[cur || b[0].size() == t].push_back(a.back());
		a.pop_back();
		cur ^= 1;
	}
	for(int j = 0; j < 2; j++){
		reverse(b[j].begin(), b[j].end());
		//for(auto i : b[j]) cout << i << " "; cout << '\n';
	}
	int tt = build(b[0], S/2);
	x[id-1] = tt;
	tt = build(b[1], S/2);
	y[id-1] = tt;
	return -id;
}
void create_circuit(int M, vector<int> A) {
	m = M, n = A.size();
	A.push_back(0);
	int t = A.size();
	while(t&(t-1)) t++;
	build(A, t);
	/*
	for(int i = 0; i < x.size(); i++) cout << i+1 << " " << x[i] << " " << y[i] << '\n';
	vector<int> st(x.size());
	for(int p = 0, i = 0; i < 5*n; i++) {
		cout << p << " ";
		if(p < 0) {
			p = -p - 1;
			int op = p;
			if(!st[p]) st[p] = 1, p = x[p];
			else st[p] = 0, p = y[p];
		} else p = -1;
	}
	cout << '\n';*/
	answer(vector<int>(m+1, -1), x, y);
}

Compilation message

doll.cpp: In function 'int build(std::vector<int>, int)':
doll.cpp:18:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   b[cur || b[0].size() == t].push_back(a.back());
      |            ~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB wrong motion
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 248 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 92 ms 7548 KB Output is correct
3 Correct 92 ms 7072 KB Output is correct
4 Correct 147 ms 9732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 92 ms 7548 KB Output is correct
3 Correct 92 ms 7072 KB Output is correct
4 Correct 147 ms 9732 KB Output is correct
5 Incorrect 185 ms 10496 KB wrong motion
6 Halted 0 ms 0 KB -