Submission #1341437

#TimeUsernameProblemLanguageResultExecution timeMemory
1341437zowiCombo (IOI18_combo)C++20
5 / 100
1 ms412 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;

//string co;

/*int press(string slo)
{
	cout << slo << endl;
	int ile = 0;
	for(int i = 0;i < slo.size();++i)
	{
		if(slo[i] != co[i]) break;
		ile++;
	}
	cout << ile << endl;
	return ile;
}*/

string guess_sequence(int n)
{
	string p;
	set<char> tab = {'A','B','X','Y'};
	if(press("AB") > 0)
	{
		if(press("A") > 0)
		{
			p = "A";
			tab.erase('A');
		}
		else
		{
			p = "B";
			tab.erase('B');
		}
	}
	else
	{
		if(press("X") > 0)
		{
			p = "X";
			tab.erase('X');
		}
		else
		{
			p = "Y";
			tab.erase('Y');
		}
	}
	vector<char> tab1;
	for(int j : tab) tab1.push_back(j);
	for(int i = 1;i < n-1;++i)
	{
		int j = press(p+tab1[0]+tab1[0]+p+tab1[0]+tab1[1]+p+tab1[0]+tab1[2]+p+tab1[1]);
		if(j == i)
		{
			p += tab1[2];
		}
		else if(j == i+1)
		{
			p += tab1[1];
		}
		else
		{
			p += tab1[0];
		}
	}
	if(press(p+"A"+p+"B") == n)
	{
		if(press(p+"A") == n)
		{
			p += "A";
	
		}
		else
		{
			p += "B";
		
		}
	}
	else
	{
		if(press(p+"X") == n)
		{
			p += "X";
		
		}
		else
		{
			p += "Y";
		
		}
	}
	return p;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...