Submission #1222762

#TimeUsernameProblemLanguageResultExecution timeMemory
1222762colossal_pepeCombo (IOI18_combo)C++20
100 / 100
7 ms524 KiB
#include "combo.h"
#include <iostream>
using namespace std;

int n;
string u;

void placeChar0(string &p) {
	if (press("AB")) p.push_back(press("A") ? 'A' : 'B');
	else p.push_back(press("X") ? 'X' : 'Y');
}

void placeTillLast(string &p) {
	for (int i = 2; i <= n - 1; i++) {
		string s = p + u[2];
		for (int i = 0; i < 3; i++) {
			s += p + u[0] + u[i];
		}
		int x = press(s);
		if (x == i) p.push_back(u[2]);
		else if (x == i + 1) p.push_back(u[0]);
		else p.push_back(u[1]);
	}
}

void placeLast(string &p) {
	if (press(p + u[0] + p + u[1]) == n - 1) p.push_back(u[2]);
	else p.push_back(press(p + u[0]) == n ? u[0] : u[1]);
}

string guess_sequence(int N) {
	n = N;
	string p = "";
	placeChar0(p);
	// cerr << p << endl;
	if (p[0] == 'A') {
		u = "BXY";
	} else if (p[0] == 'B') {
		u = "AXY";
	} else if (p[0] == 'X') {
		u = "ABY";
	} else {
		u = "ABX";
	}
	placeTillLast(p);
	// cerr << p << endl;
	if (n > 1) placeLast(p);
	// cerr << p << endl;
	return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...