This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
char getFirst(){
	if(press("AB")){
		if(press("A")) return 'A';
		return 'B';
	}
	if(press("X")) return 'X';
	return 'Y';
}
std::string guess_sequence(int N) {
	char beg=getFirst();
	string ans="", list="ABXY", choice="";
	ans.push_back(beg);
	for(char c:list){
		if(c==beg) continue;
		choice.push_back(c);
	}
	for(int i=1;i<N-1;i++){
		string query="";
		for(int i=0;i<3;i++){
			query+=ans;
			query+=choice[0];
			query+=choice[i];
		}
		query+=ans;
		query+=choice[1];
		int sz=ans.size(), ask=press(query);
		if(ask==sz+2) ans.push_back(choice[0]);
		else if(ask==sz+1) ans.push_back(choice[1]);
		else ans.push_back(choice[2]);
	}
	int sz=ans.size();
	for(int i=0;i<2;i++){
		if(press(ans+choice[i])==sz+1){
			ans.push_back(choice[i]);
			return ans;
		}
	}
	ans.push_back(choice[2]);
	return ans;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |