Submission #167123

#TimeUsernameProblemLanguageResultExecution timeMemory
167123minseo852Combo (IOI18_combo)C++11
100 / 100
53 ms692 KiB
#include <combo.h>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

string guess_sequence(int N)
{
	string result;
	if (press("AB") >= 1)
	{
		result = (press("A") == 1 ? "A" : "B");
	}
	else
		result = (press("X") == 1 ? "X" : "Y");
	
	if (N == 1)
		return result;

	vector<string> others = { "A", "B", "X", "Y" };
	for (int i = 0; i < 4; i++)
	if (others[i] == result)
	{
		others.erase(others.begin() + i);
		break;
	}
	

	string check;
	int size_cnt;
	for (int i = 1; i < N - 1; i++)
	{
		check = result + others[0] + result + others[1] + others[0] + result + others[1] + others[1] + result + others[1] + others[2];
		size_cnt = press(check);
		if (size_cnt == i)
			result += others[2];
		else if (size_cnt == i + 1)
			result += others[0];
		else
			result += others[1];
	}

	if (press(result + others[0] + result + others[1]) == N)
	{
		result += (press(result + others[0]) == N ? others[0] : others[1]);
	}
	else
		result += others[2];


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