# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
228774 | two_sides | 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 "combo.h"
using namespace std;
string guess_sequence(int n){
string res; vector <char> c = {'A', 'B', 'X', 'Y'};
if (press("AB") >= 1) res = press("A") ? "A" : "B";
else res = press("X") ? "X" : "Y";
c.erase(find(c.begin(), c.end(), res[0]));
while (int(size(res)) <= n - 2){
int que = press(res + c[0] + res + c[1] + c[0] + res + c[1] + c[1] + res + c[1] + c[2]);
if (que == size(res)) res.push_back(c[2]);
if (que == size(res) + 1) res.push_back(c[0]);
if (que == size(res) + 2) res.push_back(c[1]);
}
if (int(size(res)) < n){
if (press(res + c[0]) == n) res.push_back(c[0]);
else if (press(res + c[1]) == n) res.push_back(c[1]);
else res.push_back(c[2]);
}
return res;
}