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) {
vector<char> seq={'A','B','X','Y'};
string s = "";
int ab=press("AB");
if(ab>=1)
{
int aa=press("A");
if(aa==1)
{
s+='A';
}
else
{
s+='B';
}
}
else
{
int xx=press("X");
if(xx==1)
{
s+='X';
}
else
{
s+='Y';
}
}
if(N == 1) {
return s;
}
if(s[0] == 'A'){
seq.erase(seq.begin());
}
else if(s[0] == 'B'){
seq.erase(seq.begin() + 1);
}
else if(s[0] == 'X'){
seq.erase(seq.begin() + 2);
}
else{
seq.erase(seq.begin() + 3);
}
for(int i = 2; i < N; i++)
{
string prv=s+seq[0];
string vtor=s+seq[1]+seq[2];
string tret=s+seq[1]+seq[1];
string cet=s+seq[1]+seq[0];
string tmp = "";
tmp += prv;
tmp += vtor;
tmp += tret;
tmp += cet;
int nxt=press(tmp);
if(nxt>=1+i)s+=seq[1];
else if(nxt==i)s+=seq[0];
else s+=seq[2];
}
for(int i = 0; i < 2; i++){
string tmp = s + seq[i];
if(press(tmp) == N){
return tmp;
}
}
s += seq[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |