Submission #204473

#TimeUsernameProblemLanguageResultExecution timeMemory
204473andriiCombo (IOI18_combo)C++14
100 / 100
63 ms568 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string a[] = {"A", "B", "X", "Y"};
string guess_sequence(int N) {
	int v0 = press(string("AB"));
	string p = "";
	int f = 0;
	if(v0 > 0){
		int b = press(string("A"));
		if(b > 0) p ="A";
		else p="B", f= 1;
	}else{
		int b = press(string("X"));
		if(b > 0) p ="X", f=2;
		else p="Y", f=3;
	}
	for(int i = 1;i<N-1;i++){
		string q = p;
		q += a[(f+1)&3];
		q += a[(f+1)&3];
		q += p;
		q += a[(f+1)&3];
		q += a[(f+2)&3];
		q += p;
		q += a[(f+1)&3];
		q += a[(f+3)&3];
		q += p;
		q += a[(f+2)&3];
		//cout << q << '\n';
		int v = press(q);
		int n = p.length();
		if(v == n+2) p += a[(f+1)&3];
		if(v == n+1) p += a[(f+2)&3];
		if(v == n) p += a[(f+3)&3];
		//cout << p << '\n';
	}
	if(N > 1){
		string q = p;
		q += a[(f+1)&3];
		q += p;
		q += a[(f+2)&3];
		//cout << q << '\n';
		int v = press(q);
		int n = p.length();		
		if(v == n){
			p += a[(f+3)&3];
		}else{
			string q = p;
			q += a[(f+1)&3];
			v = press(q);
			if(v == n) p += a[(f+2)&3];
			else p += a[(f+1)&3];
		}
	}
	return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...