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;
array<char, 4> arr = {'A', 'B', 'Y', 'X'};
string guess_sequence(int N) {
char f = 'N';
for (int i = 0; i < 3; i++)
{
string st = "";
st += arr[i];
if (press(st))
{
f = arr[i];
break;
}
}
if (f=='N') f = 'X';
string s = "";
s += f;
for (int i = 1; i < N; i++)
{
if (f == 'A') s+='B';
else s+='A';
}
int j = press(s);
while (j != N)
{
string ss= "";
for (int i = 0; i < N; i++)
{
if (i < j) ss+=s[i];
else if (i==j && f != 'X') ss+='X';
else if (i==j && f=='X') ss+='Y';
else if (f =='A') ss+='B';
else ss += 'A';
}
int nj = press(ss);
if (nj==j)
{
if (f == 'X' || f == 'Y') ss[nj] = 'B';
else ss[nj] = 'Y';
nj++;
}
s = ss;
j=nj;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |