# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750202 | cheat_when_I_was_young | 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.
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n) {
int coins;
string ans;
coins = press("AB");
if (coins) {
coins = press("A");
if (coins) ans[0] = 'A';
else ans[0] = 'B';
} else {
coins = press("X");
if (coins) ans[0] = 'X';
else ans[0] = 'Y';
}
vector<string> d, e;
vector<char> c = {'A', 'B', 'X', 'Y'};
if (ans[0] == "A") {
d = {"B", "XB", "XX", "XY"};
e = {"Y", "B", "X"};
} else if (ans[0] == "B") {
d = {"A", "XA", "XX", "XY"};
e = {"Y", "A", "X"};
} else if (ans[0] == "X") {
d = {"A", "YA", "YB", "YY"};
e = {"B", "A", "Y"};
} else if (ans[0] == "Y") {
d = {"A", "XA", "XB", "XX"};
e = {"B", "A", "X"};
}
while (ans.size() < n-1) {
coins = press(ans + d[0] + ans + d[1] + ans + d[2] + ans + d[3]);
ans += e[coins - ans.size()];
}
for (int i = 0; i < c.size();) {
if (c[i] == ans[0]) c.erase(c.begin() + i);
else ++i;
}
for (int i = 0; i < 2; ++i) {
coins = press(ans + c[i]);
if (coins) {
ans += c[i];
break;
}
}
if (ans.size() < n) ans += c[2];
return ans;
}