# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029969 | thabumi | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
using namespace std;
string fiAndLa(string pref) {
string A = "A";
string B = "B";
string C = "X";
string D = "Y";
string AA = A + A, AB = A + B, AC = A + C, AD = A + D,
BA = B + A, BB = B + B, BC = B + C, BD = B + D,
CA = C + A, CB = C + B, CC = C + C, CD = C + D,
DA = D + A, DB = D + B, DC = D + C, DD = D + D;
string res = "";
int coin = press(pref + AB);
if (coin > pref.size()) {
coin = press(pref + A);
if (coin == pref.size() + 1) {
res += A;
}
else {
res += B;
}
}
else {
coin = press(pref + C);
if (coin == pref.size() + 1) {
res += C;
}
else {
res += D;
}
}
return res;
}
std::string guess_sequence(int N) {
string A = "A";
string B = "B";
string C = "X";
string D = "Y";
string AA = A + A, AB = A + B, AC = A + C, AD = A + D,
BA = B + A, BB = B + B, BC = B + C, BD = B + D,
CA = C + A, CB = C + B, CC = C + C, CD = C + D,
DA = D + A, DB = D + B, DC = D + C, DD = D + D;
string res = "";
int coin;
if (N == 1) {
res += fiAndLa(res);
}
else if (N == 2) {
res += fiAndLa(res);
res += fiAndLa(res);
}
else {
res += fiAndLa(res);
string fi = res;
for (int i = 2; i <= N - 1; i++) {
if (fi == A) {
coin = press(res + BB + res + BC + res + BD + res + C);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += D;
}
else if (fi == B) {
coin = press(res + AA + res + AC + res + AD + res + C);
if (coin == res.size() + 2) {
res += A;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += D;
}
else if (fi == C) {
coin = press(res + BB + res + BC + res + BD + res + A);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += A;
}
else res += D;
}
else {
coin = press(res + BB + res + BC + res + BD + res + C);
if (coin == res.size() + 2) {
res += B;
}
else if (coin == res.size() + 1) {
res += C;
}
else res += A;
}
}
res += fiAndLa(res);
}
return res;
}