#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
string all = "ABXY";
string p;
// Safely guess the first character
for (char c : all) {
if (press(string(1, c)) == 1) {
p += c;
break;
}
}
// Assign the other 3 letters
string rest;
for (char c : all) {
if (c != p[0]) rest += c;
}
string fix1 = string(1, rest[0]);
string fix2 = string(1, rest[1]);
string fix3 = string(1, rest[2]);
// Loop to guess remaining characters
while (p.size() < N) {
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;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |