Submission #1197839

#TimeUsernameProblemLanguageResultExecution timeMemory
1197839MateiKing80Mechanical Doll (IOI18_doll)C++17
37 / 100
75 ms26636 KiB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> ansX, ansY, ansLegit;
int maxx = 1;

void build(int loc, vector<int> a) {
	if (a.size() % 2 == 1) {
		a.push_back(-1);
		for (int i = a.size() - 1; i; i --)
			swap(a[i], a[i - 1]);
	}
	vector<int> l, r;
	int pos = 0;
	for (auto i : a) {
		(pos ? r : l).push_back(i);
		pos ^= 1;
	}
	if (l.size() == 1)
		ansX[-loc - 1] = l[0];
	else if (*max_element(l.begin(), l.end()) == -1)
		ansX[-loc - 1] = -1;
	else {
		ansX[-loc - 1] = -(++ maxx);
		build(-maxx, l);
	}
	if (r.size() == 1)
		ansY[-loc - 1] = r[0];
	else if (*max_element(r.begin(), r.end()) == -1)
		ansY[-loc - 1] = -1;
	else {
		ansY[-loc - 1] = -(++ maxx);
		build(-maxx, r);
	}
}

void create_circuit(int m, vector<int> a) {
	int n = a.size();
	a.push_back(0);
	ansLegit.resize(m + 1);
	ansX.resize(10 * n + 100);
	ansY.resize(10 * n + 100);
	for (int i = 0; i <= m; i ++)
		ansLegit[i] = -1;
	build(-1, a);
	ansX.resize(maxx);
	ansY.resize(maxx);
	answer(ansLegit, ansX, ansY);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...