Submission #84831

#TimeUsernameProblemLanguageResultExecution timeMemory
84831SirCenessCombo (IOI18_combo)C++14
5 / 100
2 ms256 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
	
	string head = "";
	string str = "";
	str = "AB";
	if (press(str)){
		str = "A";
		if (press(str)){
			head = "A";
		} else head = "B";
	} else {
		str = "X";
		if (press(str)){
			head = "X";
		} else head = "Y";
	}
	
	string a, b, c;
	if (head[0] == 'A'){
		a = "B";
		b = "X";
		c = "Y";
	} else if (head[0] == 'B'){
		a = "A";
		b = "X";
		c = "Y";
	} else if (head[0] == 'X'){
		a = "B";
		b = "A";
		c = "Y";
	} else if (head[0] == 'Y'){
		a = "B";
		b = "X";
		c = "A";
	}
	
	for (int i = 1; i < N-1; i++){
		str = "";
		str += head;
		str += a;
		str += a;
		str += head;
		str += a;
		str += b;
		str += head;
		str += a;
		str += c;
		str += head;
		str += b;
		
		int coins = press(str);
		if (coins == i+2) head += a;
		else if (coins == i+1) head += b;
		else if (coins == i) head += c;
		else cout << "FATAL ERROR" << endl;
		
	}
	
	str = "";
	str += head;
	str += a;
	str += head;
	str += b;
	
	if (press(str) == N-1){
		head += c;
	} else {
		str = head + a;
		if (press(str) == N-1) head += b;
		else head += a;
	}
	
	return head;
}

/*
	string p = "";
	for (int i = 0; i < 4 * N; ++i) {
		p += 'A';
	}
	int coins = press(p);
	string S = "";
	for (int i = 0; i < N; ++i) {
		S += 'A';
	}
	return S;
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...