Submission #694133

#TimeUsernameProblemLanguageResultExecution timeMemory
694133amirhoseinfar1385Combo (IOI18_combo)C++17
100 / 100
32 ms660 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
	char all[4];
	int fake=press("AB");
	if(fake==0){
		fake=press("X");
		if(fake==0){
			all[0]='Y';
			all[1]='A';
			all[2]='B';
			all[3]='X';
		}
		else{
			all[0]='X';
			all[1]='A';
			all[2]='Y';
			all[3]='B';
		}
	}
	else{
		fake=press("A");
		if(fake==1){
			all[0]='A';
			all[1]='B';
			all[2]='X';
			all[3]='Y';
		}
		else{
			all[0]='B';
			all[1]='A';
			all[2]='X';
			all[3]='Y';
		}
	}
	string res;
	int unnow=1;
	res.push_back(all[0]);
	int now=2;
	for(;now<n;){
	    unnow=now-1;
		fake=press(res+all[1]+all[1]+res+all[1]+all[2]+res+all[2]+all[1]);
		if(fake==unnow){
			res+=all[3];
			now++;
			continue;
		}
		else if(fake==unnow+1){
			fake=press(res+all[2]+all[2]);
			if(fake==unnow+2){
			    res+=all[2];
			    res+=all[2];
			    now+=2;
			    continue;
			}
			if(fake==unnow+1){
			    res+=all[2];
			    res+=all[3];
			    now+=2;
			    continue;
			}
			res+=all[1];
			res+=all[3];
			now+=2;
			continue;
		}
		else{
			fake=press(res+all[1]+all[1]);
			if(fake==unnow){
				res+=all[2];
				res+=all[1];
				now+=2;
				continue;
			}
			else if(fake==unnow+1){
				res+=all[1];
				res+=all[2];
				now+=2;
				continue;
			}
			else{
				res+=all[1];
				res+=all[1];
				now+=2;
				continue;
			}
		}
	}
	if(now==n){
		fake=press(res+all[1]+res+all[2]);
		if(fake==n){
			fake=press(res+all[1]);
			if(fake==n){
				res+=all[1];
			}
			else{
				res+=all[2];
			}
		}
		else{
			res+=all[3];
		}
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...