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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n) {
string alphabet = "ABXY", answer = "";
int first_letter = press("AB");
if (first_letter) {
if (press("A")) {
first_letter = 0;
answer = "A";
} else {
first_letter = 1;
answer = "B";
}
} else {
if (press("X")) {
first_letter = 2;
answer = "X";
} else {
first_letter = 3;
answer = "Y";
}
}
if (n == 1) {
return answer;
}
for (int i = 0; i < n - 2; ++i) {
int current = 0;
string query = "";
for (int j = 0; j < 4; ++j) {
if (j != first_letter) {
if (current == 1) {
query += answer + alphabet[j];
} else if (current == 2) {
for (int k = 0; k < 4; ++k) {
if (k != first_letter) {
query += answer + alphabet[j] + alphabet[k];
}
}
}
++current;
}
}
int result = press(query);
current = answer.length();
for (int j = 0; j < 4; ++j) {
if (j != first_letter) {
if (result == current) {
answer += alphabet[j];
}
++current;
}
}
}
if (press(answer + "A" + answer + "B") == n) {
if (press(answer + "A") == n) {
return answer + "A";
} else {
return answer + "B";
}
} else {
if (press(answer + "X") == n) {
return answer + "X";
} else {
return answer + "Y";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |