Submission #414645

#TimeUsernameProblemLanguageResultExecution timeMemory
414645TemmieCombo (IOI18_combo)C++17
100 / 100
49 ms580 KiB
#include "combo.h"
#include <bits/stdc++.h>

//int press(std::string p) {
	
	//return 0;
//}

std::string ch = "ABXY";

std::string guess_sequence(int n) {
	std::string s = "";
	if (press("AB")) {
		if (press("A")) s = "A";
		else s = "B";
	} else if (press("X")) s = "X";
	else s = "Y";
	assert((int)s.length() == 1);
	if (n == 1) {
		return s;
	}
	std::string t = "";
	for (char c : ch) {
		if (c != s[0]) {
			t += c;
		}
	}
	for (int i = 1; i < n - 1; i++) {
		std::string now = s + t[0] + s + t[1] + t[0] + s + t[1] + t[1] + s + t[1] + t[2];
		int res = press(now);
		if (res == (int)s.length()) s += t[2];
		else if (res == (int)s.length() + 1) s += t[0];
		else s += t[1];
	}
	if (press(s + t[0]) == (int)s.length() + 1) s += t[0];
	else if (press(s + t[1]) == (int)s.length() + 1) s += t[1];
	else s += t[2];
	return s;
}

//int main() {
	
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...