Submission #158117

#TimeUsernameProblemLanguageResultExecution timeMemory
158117johuthaCombo (IOI18_combo)C++14
5 / 100
2 ms264 KiB
#include "combo.h"
#include <vector>

using namespace std;

string guess_sequence(int N) 
{
	string curr = "";
	string other;
	if (press("AB"))
	{
		if (press("A")) 
		{
			curr.push_back('A');
			other = "BXY";
		}
		else 
		{
			curr.push_back('B');
			other = "AXY";
		}
	}
	else
	{
		if (press("X"))
		{
			curr.push_back('X');
			other = "ABY";
		} 
		else
		{
			curr.push_back('Y');
			other = "ABX";
		}
	}
	for (int i = 1; i < N - 1; i++)
	{
		string ask = curr + other[0] + curr + other[1] + other[0] + curr + other[1] + other[1] + curr + other[1] + other[2];
		int res = press(ask);
		if (res == i)
		{
			curr.push_back(other[2]);
		}
		else if (res == i + 1)
		{
			curr.push_back(other[0]);
		}
		else
		{
			curr.push_back(other[1]);
		}
	}
	if (press(curr + other[0] + curr + other[1]) != N)
	{
		return curr + other[2];
	}
	else if (press(curr + other[0]) == N) return curr + other[0];
	return curr + other[1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...