Submission #696464

#TimeUsernameProblemLanguageResultExecution timeMemory
696464Elvin_FritlCombo (IOI18_combo)C++17
100 / 100
31 ms744 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
 
string guess_sequence(int n) {
	char p=' ';
	string c="";
	vector<char> v(0),b={'A','B','X','Y'};
	int ab=press("AB"),ax=press("AX");
	if (ab&&ax) p='A';
	else if (ab) p='B';
	else if (ax) p='X';
	else p='Y';
	for (char ch:b){
		if (p!=ch) v.push_back(ch);
	}
	c+=p;
	if (n==1) return c;
	for (int i=1;i<n-1;i++){
		string s1=c+v[0],s2=c+v[1];
		string s2a=s2+v[0],s2b=s2+v[1],s2c=s2+v[2];
		int res=press(s1+s2a+s2b+s2c);
		if (res==i+2) c+=v[1];
		else if (res==i+1) c+=v[0];
		else c+=v[2];
	}
	int toto1=press(c+v[0]),toto2=press(c+v[1]);
	if (toto1==n) return c+v[0];
	else if (toto2==n) return c+v[1];
	else return c+v[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...