Submission #732227

#TimeUsernameProblemLanguageResultExecution timeMemory
732227baneCombo (IOI18_combo)C++17
97 / 100
40 ms588 KiB
#include<bits/stdc++.h>
using namespace std;
int press(std::string p);

string guess_sequence(int N){
	vector<string>frst = {"A", "B", "X", "Y"};
	string ans = "";
	if (press("AB")){
		if (press("A")){
			ans += "A";
			frst.erase(frst.begin());
		}else{
			ans += "B";
			frst.erase(frst.begin()+1);
		}
	}else{
		if (press("X")){
			ans += "X";
			frst.erase(frst.begin()+2);
		}else{
			ans += "Y";
			frst.erase(frst.begin() + 3);
		} 
	}
	for (int i = 0 ; i < N - 2; i++){
		string ask = ans + frst[0] + frst[1] + ans + frst[0] + frst[0] + ans + frst[0] + frst[2] + ans + frst[1];
		int res = press(ask) - (int)ans.size();
		if (res == 2){
			ans+=frst[0];
		}else if (res == 1){
			ans += frst[1];
		}else{
			ans += frst[2];
		}
	}
	for (int j = 0 ; j < 2; j++){
		if (press(ans + frst[j]) > (int)ans.size()){
			ans += frst[j];
			break;
		}
	}
	if ((int)ans.size() != N)ans+=frst[2];
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...