Submission #1029308

#TimeUsernameProblemLanguageResultExecution timeMemory
1029308XJP12Combo (IOI18_combo)C++14
100 / 100
22 ms1924 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
// int press(string p){

// }

string guess_sequence(int n){
	string s;
	string temp;
	int x=press("AB");
	string f;
	string combi;
	string other;
	string last;
	if(x>=1){
		x = press("A");
		if(x==1){
			f="A";
			combi="X";
			other="B";
			last="Y";
		}else{
			f="B";
			combi="X";
			other="A";
			last="Y";
		}
	}else{
		x = press("X");
		if(x==1){
			f="X";
			combi="A";
			other="B";
			last="Y";
		}else{
			f="Y";
			combi="A";
			other="B";
			last="X";
		}
	}
	s=f;
	while((int)s.size()!=n){
		int size=(int)s.size();
		if(size==n-1){
			temp=s+combi+s+other;
			x=press(temp);
			if(x==size+1){
				temp=s+combi;
				x=press(temp);
				if(x==size+1){
					s+=combi;
				}else{
					s+=other;
				}
			}else{
				s+=last;
			}
			break;
		}
		temp=s+combi+combi;
		temp+=s+combi+other;
		temp+=s+combi+last;
		temp+=s+other;
		x=press(temp);
		if(x==size+2){
			s+=combi;
		}else{
			if(x==size+1){
				s+=other;
			}else{
				s+=last;
			}
		}
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...