This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
using namespace std;
#define str string
#define p press
str guess_sequence(int N) {
str S[4] = {"A", "B", "X", "Y"};
// Part 0: Short Case
if (N == 1) {
if (p("AB") == 1) {
if (p("A") == 1) return "A";
else return "B";
} else {
if (p("X") == 1) return "X";
else return "Y";
}
} else {
// Part 1: Determine the first letter (2)
int initCombo = p("XYX") >= 1 ? 2 : 0;
if (initCombo) initCombo += p("XAXBXY") <= 1 ? 1 : 0;
else initCombo += p("AXAYAB") <= 1 ? 1 : 0;
int lenCombo = 1;
str combo = S[initCombo];
for (int Si = initCombo; Si < 3; Si++) S[Si] = S[Si + 1];
// Part 2: Determine letters between the first and last, if any (1 per)
str query; int lenQuery;
while (lenCombo < N - 1) {
query = combo + S[0] + S[0] +
combo + S[0] + S[1] +
combo + S[0] + S[2] +
combo + S[1];
lenQuery = p(query);
if (lenQuery == lenCombo + 2) combo += S[0];
else if (lenQuery == lenCombo + 1) combo += S[1];
else combo += S[2];
lenCombo += 1;
}
// Part 3: Determine the last letter when necessary (2)
if (lenCombo == N) return combo;
else {
if (p(combo + S[0]) == N) return (combo + S[0]);
else if (p(combo + S[1]) == N) return (combo + S[1]);
else return (combo + S[2]);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |