# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199987 | Mr_turtle | Combo (IOI18_combo) | C++14 | 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 ans;
string rest;
string guess_sequence(int n) {
string a = "AB";
if (press(a))
{
a = "A";
if (press(a))
ans = "A";
else
ans = "B";
}
else
{
a = "X";
if (press(a))
ans = "X";
else
ans = "Y";
}
rest = "";
for (i = 0;i < 4;i++)
{
if ("ABXY"[i] == ans[0]) continue;
rest += "ABXY"[i];
}
for (int i = 2;i < n;i++)
{
int prs = press(ans + rest[1] + ans + rest[2] + rest[0] + ans + rest[2] + rest[1] + ans + rest[2] + rest[2]);
prs -= (i - 1);
ans += rest[prs];
}
if (press(ans + "A" + ans + "B") == n)
{
if (press(ans + "A") == n)
ans += "A";
else
ans += "B";
}
else
{
if (press(ans + "X") == n)
ans += "X";
else
ans += "Y";
}
return ans;
}