Submission #1093236

#TimeUsernameProblemLanguageResultExecution timeMemory
1093236emptypringlescanCombo (IOI18_combo)C++17
100 / 100
17 ms1260 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

string guess_sequence(int N) {
	string cor="";
	int x=press("AB");
	int c=1;
	if(x==2){
		cor="AB";
		c=2;
	}
	else if(x==1){
		x=press("A");
		if(x>0) cor="A";
		else cor="B";
	}
	else{
		x=press("XA");
		if(x==2){
			cor="XA";
			c=2;
		}
		else if(x==1) cor="X";
		else cor="Y";
	}
	string arr[3];
	if(cor[0]=='A'){
		arr[0]="B"; arr[1]="X"; arr[2]="Y";
	}
	if(cor[0]=='B'){
		arr[0]="A"; arr[1]="X"; arr[2]="Y";
	}
	if(cor[0]=='X'){
		arr[0]="A"; arr[1]="B"; arr[2]="Y";
	}
	if(cor[0]=='Y'){
		arr[0]="A"; arr[1]="B"; arr[2]="X";
	}
	
	while(c<N-1){
		x=press(cor+arr[0]+arr[0]+cor+arr[1]+arr[1]+cor+arr[1]+arr[2]);
		if(x-c==2){
			x=press(cor+arr[1]+arr[1]);
			if(x-c==2) cor+=arr[1]+arr[1];
			else if(x-c==1) cor+=arr[1]+arr[2];
			else cor+=arr[0]+arr[0];
			c+=2;
		}
		else if(x-c==1){
			x=press(cor+arr[0]+arr[1]);
			if(x-c==2) cor+=arr[0]+arr[1];
			else if(x-c==1) cor+=arr[0]+arr[2];
			else cor+=arr[1]+arr[0];
			c+=2;
		}
		else{
			cor+=arr[2];
			c++;
		}
	}
	if(c<N){
		x=press(cor+arr[0]);
		if(x-c) cor+=arr[0];
		else{
			x=press(cor+arr[1]);
			if(x-c) cor+=arr[1];
			else cor+=arr[2];
		}
	}
	return cor;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...