#include "bits/stdc++.h"
using namespace std;
int press(string p);
string guess_sequence(int N) {
char f = 'A';
if (press("B") == 1) {
f = 'B';
}
else if (press("X") == 1) {
f = 'X';
}
else if (press("Y") == 1) {
f = 'Y';
}
string s1, s2, s3;
s1 += f, s2 += f, s3 += f;
if (N == 1) {
return s1;
}
string s = "ABXY";
s.erase(s.find(f), 1);
int cur = 1;
while (s1.size() < N) {
for (int i = 0; i < 3; i++) {
s1 += s[i];
s2 += s[(i+1)%3];
s3 += s[(i+2)%3];
if (press(s1 + s2 + s3) == cur+1) {
cur++;
break;
}
s1.pop_back();
s2.pop_back();
s3.pop_back();
}
}
if (press(s1.substr(0, 2) + s2.substr(0, 2)) == 2) {
if (press(s1.substr(0, 2)) == 2) return s1;
else return s2;
} else return s3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |