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"
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int n) {
string p;
int l = 0;
int ind[n];
for(int i = 0;i<n;i++)
ind[i] = 0;
char arr[] = {'A', 'B', 'X', 'Y'};
int sum = 0;
int maks = 0;
while(sum<n+2)
{
if(l==n)
break;
sum++;
if((int)p.size() == 0)
{
p.push_back('A');
ind[0] = 0;
l = press(p);
continue;
}
char poc = p[0];
if(sum<=n)
{
int i = 0;
while(arr[i] == poc)
{
i++;
}
ind[sum] = i;
p.push_back(arr[i]);
}
for(int j = l;j<(int)p.size()-1;j++)
{
int i = ind[j] + 1;
if(i==4)
i = 0;
while(arr[i] == poc)
{
i++;
}
ind[j] = i;
p[j] = arr[i];
}
if(maks&&sum>=n)
{
int i = ind[n-1] + 1;
if(i==4)
i = 0;
while(arr[i] == poc)
{
i++;
}
ind[n-1] = i;
p[n-1] = arr[i];
}
if(sum==n)
maks++;
cout<<p<<endl;
l = press(p);
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |