Submission #417340

# Submission time Handle Problem Language Result Execution time Memory
417340 2021-06-03T14:58:11 Z pavement Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
52 ms 7712 KB
#include "Anna.h"
#include <bits/stdc++.h>
 
void Anna(int N, std::vector<char> S) {
	for (int i = 0; i < N; i++) {
		if (S[i] == 'X') Send(0), Send(0);
		else if (S[i] == 'Y') Send(0), Send(1);
		else Send(1), Send(0);
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
 
void Bruno(int N, int L, std::vector<int> A) {
	std::vector<char> B(N, 0);
	std::vector<bool> r(N, 0);
	std::vector<int> tocl(N, -1), tocr(N, -1);
	std::vector<std::pair<int, int> > segs;
	for (int i = 0; i < L; i += 2) {
		if (A[i] == 0 && A[i + 1] == 0) B[i] = 'X';
		else if (A[i] == 0 && A[i + 1] == 1) B[i] = 'Y';
		else B[i] = 'Z';
	}
	for (int i = 0, cl = -1; i < N; i++) {
		if (B[i] == 'X') cl = i;
		else if (B[i] == 'Y') tocl[i] = cl;
	}
	for (int i = N - 1, cr = -1; i >= 0; i--) {
		if (B[i] == 'Z') cr = i;
		else if (B[i] == 'Y') tocr[i] = cr;
	}
	for (int i = 0; i < N; i++)
		if (B[i] == 'Y' && tocl[i] != -1 && tocr[i] != -1) {
			segs.emplace_back(tocl[i], tocr[i]);
		}
	std::sort(segs.begin(), segs.end());
	segs.erase(std::unique(segs.begin(), segs.end()), segs.end());
	for (auto i : segs) {
		assert(B[i.first] == 'X' && B[i.second] == 'Z');
		int pos = -1;
		for (int j = i.first; j <= i.second; j++)
			if (!r[j] && B[j] == 'Y') pos = j;
		assert(pos != -1);
		for (int j = i.first + 1; j < pos; j++)
			if (!r[j]) r[j] = 1, Remove(j);
		for (int j = pos + 1; j < i.second; j++)
			if (!r[j]) r[j] = 1, Remove(j);
		Remove(pos);
	}
	for (int i = 0; i < N; i++)
		if (!r[i]) Remove(i);
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 612 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 7712 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -