# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1278669 | IBory | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string P = "ABXY";
int n = press("AB");
chat c = ' ';
if (n) c = (press("A") ? 'A' : 'B');
else c = (press("X") ? 'X' : 'Y');
P.erase(P.begin() + P.find(c));
string S; S.push_back(c);
string P1, P21, P22, P23;
P1.push_back(P[0]);
P21.push_back(P[1]); P21.push_back(P[0]);
P22.push_back(P[1]); P22.push_back(P[1]);
P23.push_back(P[1]); P23.push_back(P[2]);
for (int i = 2; i < N; ++i) {
string T = S + P1 + S + P21 + S + P22 + S + P23;
int n = press(T);
if (n == (i - 1)) S.push_back(P[2]);
else if (n == i) S.push_back(P[0]);
else S.push_back(P[1]);
}
for (int i = 0; i < 3; ++i) {
S.push_back(P[i]);
if (i == 2 || guess(S) == N) return S;
S.pop_back();
}
return "";
}