Submission #369795

#TimeUsernameProblemLanguageResultExecution timeMemory
369795flappybirdCombo (IOI18_combo)C++14
97 / 100
50 ms736 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
	string s;
	s = "A";
	int res = press(s);
	char a, b, c, d;
	if (res == 1) {
		a = 'A';
		b = 'B';
		c = 'X';
		d = 'Y';
	}
	else {
		s = "B";
		res = press(s);
		if (res == 1) {
			a = 'B';
			b = 'A';
			c = 'X';
			d = 'Y';
		}
		else {
			s = "X";
			res = press(s);
			if (res == 1) {
				a = 'X';
				b = 'B';
				c = 'A';
				d = 'Y';
			}
			else {
				a = 'Y';
				b = 'B';
				c = 'X';
				d = 'A';
			}
		}
	}
	int i;
	string S;
	S += a;
	if (N == 1) return S;
	for (i = 2; i <= N - 1; i++) {
		string g1, g2, g3, g4;
		string g;
		g = S + b;
		g1 = g + b;
		g2 = g + c;
		g3 = g + d;
		g4 = S + c;
		res = press(g1 + g2 + g3 + g4);
		if (res == i + 1) S += b;
		if (res == i) S += c;
		if (res == i - 1) S += d;
	}
	if (press(S + b) == N) return S + b;
	if (press(S + c) == N) return S + c;
	return S + d;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...