#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string r="ABXY";
string guess_sequence(int n) {
string p="", a=""; int y=press("AB");
if(y>=1)
{
y=press("A"); if(y==1)p="A"; else p="B";
}
else
{
y=press("X"); if(y==1)p="X"; else p="Y";
}
for(int i=0; i<4; i++)
{
string s=""; s.push_back(r[i]);
if(s!=p)a.push_back(r[i]);
}
string x, y1, z; x.push_back(a[0]);
y1.push_back(a[1]); z.push_back(a[2]);
for(int i=0; i<n-2; i++)
{
y=press(p+x+p+y1+y1+p+y1+x+p+y1+z);
if(y==p.size()){p+=z;} else if(y==p.size()+1)p+=x;
else if(y==p.size()+2)p+=y1;
}
if(n==1){return p; }y=press(p+y1); if(y==n)p+=y1;
else{y=press(p+x); if(y==n)p+=x; else p+=z;}
return p;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |