# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79040 | reda | 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 <bits/stdc++.h>
using namespace std;
char c[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n)
{
string pref;
int t = press("AB");
if(t > 0)
{
int a = press("A");
if(a == 1) pref = "A";
else pref = "B";
}
else
{
int a = press("X");
if(a == 1) pref = "X";
else pref = "Y";
}
if(pref.empty()) pref.push_back(c[3]);
for(int i = 0; i < 4; i++)
if(c[i] == pref[0]) swap(c[i], c[0]);
for(int j = 0; j < n - 2; j++)
{
string aux = pref + c[1] + pref + c[2] + c[3] + pref + c[2] + c[1] + pref + c[2] + c[2];
int ans = press(aux);
if(ans == pref.size() + 1) pref.push_back(c[1]);
else if(ans == pref.size() + 2) pref.push_back(c[2]);
else pref.push_back(c[3]);
}
if(n != 1)
{
for(int i = 1; i < 3; i++)
{
string aux = pref + c[i];
if(press(aux) == pref.size() + 1)
{
return aux;
}
}
pref += c[3];
}
return pref;
}