제출 #138484

#제출 시각아이디문제언어결과실행 시간메모리
138484Mahdi_JfriCombo (IOI18_combo)C++14
100 / 100
52 ms608 KiB
#include "combo.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

string ch[] = {"A" , "B" , "X" , "Y"};

string guess_sequence(int n)
{
	string p;
	if(press(ch[0] + ch[1]))
	{
		if(!press(ch[0]))
			swap(ch[0] , ch[1]);
	}
	else
	{
		if(press(ch[2]))
			swap(ch[2] , ch[0]);
		else
			swap(ch[3] , ch[0]);
	}

	p = ch[0];
	for(int i = 1; i < n - 1; i++)
	{
		string tmp = p + ch[1] + p + ch[2] + ch[1] + p + ch[2] + ch[2] + p + ch[2] + ch[3];

		int x = press(tmp);
		if(x == (int)p.size())
			p += ch[3];
		else if(x == (int)p.size() + 1)
			p += ch[1];
		else
			p += ch[2];
	}
	
	if(n == 1)
		return p;

	if(press(p + ch[1]) == n)
		p += ch[1];
	else
	{
		if(press(p + ch[2]) == n)
			p += ch[2];
		else
			p += ch[3];
	}

	return p;
}





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