# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1142370 | FZ_Laabidi | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string P = "";
set<char> tr = {'A', 'B', 'X', 'Y'};
int c = press("AB");
if(c>=1) {
c = press("A");
if (c==1)P+="A";
else P+="B";
}
else if (c==0) {
c = press("X");
if (c==1)P+="X";
else P+="Y";
}
tr.erase(P[0]);
char B, X, Y;
c=0;
for (auto x: tr) {
if (c==0)B = x;
if (c==1)X = x;
if (c==2)Y = x;
c++;
}
int count =1;
for (int i=0; i<=N-2; i++) {
string ty = P + X + P + B + X + P + B + Y + P + B + B;
c = press(ty);
if (c==count)P+=X;
else if (c==count)P+=B;
else P+=Y;
count++;
}
string ty= P+X+P+B;
if (N>1) {
c = press(ty);
if (c==N) {
c = press(P+X);
if (c==N)P+=X;
else P+=B
}
else P+=Y;
}
return P;
}
//Cbx-2bx=0
// bx=0;