#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
// Guessing first letter
set<string> S;
S.insert("A");
S.insert("B");
S.insert("X");
S.insert("Y");
string trash = "AB";
string p = "";
int ans = press(trash);
if (ans >= 1){
trash = "A";
ans = press(trash);
if (ans == 1) p += "A";
else p += "B";
} else {
trash = "X";
ans = press(trash);
if (ans == 1) p += "X";
else p += "Y";
}
S.erase(p);
// Remaining letters up to the (n-1)th
int c=0;
string B,X,Y;
for (auto x: S){
if (c == 0) B = x;
if (c == 1) X = x;
if (c == 2) Y = x;
c++;
}
int cnt=1;
for (int i=0;i<N-2;i++){
string trash = (p + B) + (p + X + B) + (p + X + X) + (p + X + Y);
ans = press(trash);
if (ans == cnt) p += Y;
if (ans == cnt+1) p += B;
if (ans == cnt+2) p += X;
cnt++;
}
if (N > 1){
// last letter
ans = press(p + B);
if (ans == N) p += B;
else {
ans = press(p + X);
if (ans == N) p += X;
else p += Y;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |