#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
std::string guess_sequence(int N) {
/*A B X Y*/
string p="";
string p1="AB";
int ans=press(p1);
if (ans==1 or ans==2) {
string psome="A";
int ansk=press(psome);
if (ansk==1) {
p+=psome;
}
else {
p+='B';
}
}
if (ans==0) {
string p2="X";
int ans2=press(p2);
if (ans2==1) {
p+=p2;
}
else {
p+='Y';
}
}
if (N==1) {
return p;
}
char fix1, fix2, fix3;
if (p[0] == 'X') {
fix1 = 'A';
fix2 = 'B';
fix3 = 'Y';
}
if (p[0] == 'Y') {
fix1 = 'A';
fix2 = 'B';
fix3 = 'X';
}
if (p[0] == 'A') {
fix1 = 'X';
fix2 = 'B';
fix3 = 'Y';
}
if (p[0] == 'B') {
fix1 = 'A';
fix2 = 'X';
fix3 = 'Y';
}
while (p.size() <N-1) {
string q = p + fix1 + p + fix2 + fix3 + p + fix2 + fix1 + p + fix2 + fix2;
int res = press(q);
if (res == p.size()) {
p += fix3;
} else if (res == p.size() + 1) {
p += fix1;
} else {
p += fix2;
}
}
if (press(p+fix1)==p.size()+1) {
return p+fix1;
}
else {
if (press(p+fix2)==p.size()+1) {
return p+fix2;
}
else {
return p+fix3;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |