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;
char findFirst()
{
if(press("AB"))
{
if(press("A"))
return 'A';
else
return 'B';
}
else
{
if(press("X"))
return 'X';
else
return 'Y';
}
}
string guess_sequence(int n)
{
string ans;
ans += findFirst();
if(n == 1)
return ans;
string alphabet = "ABXY";
char first=0, second=0, third=0;
for(char ch : alphabet)
{
if(ch == ans[0])
continue;
if(!first)
first=ch;
else if(!second)
second=ch;
else
third=ch;
}
for(int i=2;i<n;i++)
{
string q;
q+=ans;
q+=first;
q+=ans;
q+=second;
q+=first;
q+=ans;
q+=second;
q+=second;
q+=ans;
q+=second;
q+=third;
int x=press(q);
if(x == i)
ans += first;
if(x == i+1)
ans += second;
if(x == i-1)
ans += third;
}
string q=ans+first;
if(press(q) == n)
return q;
q=ans+second;
if(press(q) == n)
return q;
q=ans+third;
return q;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |