Submission #394425

#TimeUsernameProblemLanguageResultExecution timeMemory
394425jsannemoCombo (IOI18_combo)C++14
100 / 100
44 ms560 KiB
#include "combo.h"
#include <vector>

using namespace std;

std::string guess_sequence(int N) {
	string S;
	if (press("AB")) {
		if (press("A")) S.push_back('A');
		else S.push_back('B');
	} else if (press("X")) S.push_back('X');
	else S.push_back('Y');

	vector<char> ot;
	if (S[0] != 'A') ot.push_back('A');
	if (S[0] != 'B') ot.push_back('B');
	if (S[0] != 'X') ot.push_back('X');
	if (S[0] != 'Y') ot.push_back('Y');
	for (int i = 1; i < N - 1; i++) {
		string guess = S;
		guess.push_back(ot[0]); guess.push_back(ot[0]);
		guess += S;
		guess.push_back(ot[0]); guess.push_back(ot[1]);
		guess += S;
		guess.push_back(ot[0]); guess.push_back(ot[2]);
		guess += S;
		guess.push_back(ot[1]);
		int p = press(guess);
		if (p == i + 1) S.push_back(ot[1]);
		else if (p == i + 2) S.push_back(ot[0]);
		else S.push_back(ot[2]);
	}
	if (N > 1) {
		S.push_back(ot[0]);
		if (press(S) == N) return S;
		S.back() = ot[1];
		if (press(S) == N) return S;
		S.back() = ot[2];
	}
	return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...