Submission #360085

#TimeUsernameProblemLanguageResultExecution timeMemory
360085jesus_coconutCombo (IOI18_combo)C++17
100 / 100
59 ms592 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
	string al = "ABXY";
	string ret;
	if (press("AB")) {
		if (press("A")) ret = "A";
		else ret = "B";
	} else {
		if (press("X")) ret = "X";
		else ret = "Y";
	}
	string pos;
	for (auto c : al) if (c != ret[0]) pos += c;
	for (int i = 1; i < N - 1; ++i) {
		string q = ret + pos[0];
		for (auto c : pos) {
			q += ret + pos[1] + c;
		}
		int a = press(q);
		if (a == i) ret += pos[2];
		else if (a == i + 1) ret += pos[0];
		else ret += pos[1];
	}
	if (N > 1) {
		if (press(ret + pos[0]) == N) ret += pos[0];
		else if (press(ret + pos[1]) == N) ret += pos[1];
		else ret += pos[2];
	}
	return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...