Submission #829028

#TimeUsernameProblemLanguageResultExecution timeMemory
829028tranxuanbachCombo (IOI18_combo)C++17
5 / 100
1 ms208 KiB
#include "combo.h"

#include <bits/stdc++.h>
using namespace std;

#define isz(a) ((signed)a.size())

string alphabet = "ABXY";

string guess_sequence(int n){
	string s = "";
	// first character
	if (press("AB") == 0){
		if (press("X") == 0){
			s += "Y";
		}
		else{
			s += "X";
		}
	}
	else{
		if (press("A") == 0){
			s += "B";
		}
		else{
			s += "A";
		}
	}
	alphabet.erase(alphabet.find(s), 1);
	for (int i = 1; i < n - 1; i++){
		string query = "";
		query += s + alphabet[0] + alphabet[0];
		query += s + alphabet[0] + alphabet[1];
		query += s + alphabet[0] + alphabet[2];
		query += s + alphabet[1];
		int val = press(query);
		if (val == isz(s) + 2){
			s += alphabet[0];
		}
		else if (val == isz(s) + 1){
			s += alphabet[1];
		}
		else{
			s += alphabet[2];
		}
	}
	string query = s + alphabet[0];
	int val1 = press(query);
	query = s + alphabet[1];
	int val2 = press(query);
	if (val1 == isz(s) + 1){
		s += alphabet[0];
	}
	else if (val2 == isz(s) + 1){
		s += alphabet[1];
	}
	else{
		s += alphabet[2];
	}
	return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...