Submission #1071037

#TimeUsernameProblemLanguageResultExecution timeMemory
1071037sleepntsheepAncient Machine (JOI21_ancient_machine)C++17
5 / 100
2011 ms9916 KiB
#include "Anna.h"
#include <vector>

namespace {
}

void Anna(int N, std::vector<char> S) {
	for (int i = 0; i < N; ++i) {
		int v = S[i] - 'X';
		Send((v >> 1));
		Send(v & 1);
	}
}
#include "Bruno.h"
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

namespace {

int variable_example = 0;

int FunctionExample(int P) { return 1 - P; }

}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
	vector<int> v(N), ded(N);
	for (int i = 0; i < N; ++i)
		v[i] = 2 * A[2 * i] + A[2 * i + 1];

	vector<set<int> > oc(3);
	for (int i = 0; i < N; ++i)
		oc[v[i]].insert(i);

	if (oc[0].empty() or oc[2].empty() or *oc[0].begin() > *oc[2].rbegin()) {
		for (int i = 0; i < N; ++i) Remove(i);
		return;
	}

	int x0 = *oc[0].begin();
	int z0 = *oc[2].rbegin();

	auto REmove = [&](int i) { if (not ded[i]) Remove(i); ded[i] = 1; oc[v[i]].erase(i); };

	int at = x0;
	for (; at < z0 ;) {
		auto zi = oc[2].upper_bound(at);

		while (1) {
			auto yi = oc[1].lower_bound(*zi);
			if (yi == oc[1].begin() or *--yi < x0)
				break;
			auto xi = prev(oc[0].lower_bound(*yi));

			for (int i = *xi + 1; i < *yi; ++i) REmove(i);
			for (int i = *yi + 1; i < *zi; ++i) REmove(i);
			REmove(*yi);
			if (*xi != x0) REmove(*xi);
		}
		for (int i = *zi - 1; i > at; --i)
			REmove(i);

		at = *zi;
	}

	for (int i = 0; i < N; ++i) REmove(i);

}

Compilation message (stderr)

Bruno.cpp:11:5: warning: 'int {anonymous}::FunctionExample(int)' defined but not used [-Wunused-function]
   11 | int FunctionExample(int P) { return 1 - P; }
      |     ^~~~~~~~~~~~~~~
Bruno.cpp:9:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
    9 | int variable_example = 0;
      |     ^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...