Submission #567589

#TimeUsernameProblemLanguageResultExecution timeMemory
567589valerikkCombo (IOI18_combo)C++17
30 / 100
50 ms444 KiB
#include "combo.h"
#include <vector>
#include <string>
#include <algorithm>

std::string guess_sequence(int N) {
	static const char buttons[] = { 'A', 'B', 'X', 'Y' };

	int first;

	if (press(std::string { buttons[0], buttons[1] })) {
		if (press(std::string { buttons[0] })) {
			first = 0;
		} else {
			first = 1;
		}
	} else {
		if (press(std::string { buttons[2] })) {
			first = 2;
		} else {
			first = 3;
		}
	}

	char Y = buttons[first];
	char A = buttons[(first + 1) & 3];
	char B = buttons[(first + 2) & 3];
	char X = buttons[(first + 3) & 3];

	std::string S { Y };

	for (int i = 1; i < N; ++i) {
		if (press(S + A + S + B) == i + 1) {
			if (press(S + A) == i + 1) {
				S += A;
			} else {
				S += B;
			}
		} else {
			if (press(S + B) == i + 1) {
				S += B;
			} else {
				S += X;
			}
		}
	}

	return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...