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;
string guess_sequence(int N) {
char map[] = {'A', 'B', 'X', 'Y'};
string ans = "";
// Determine first letter
int first_idx;
if (press("AB")) {
if (press("A")) first_idx = 0;
else first_idx = 1;
} else {
if (press("X")) first_idx = 2;
else first_idx = 3;
}
swap(map[0], map[first_idx]);
ans += map[0];
// Add letters form 1 to n-2
for (int i = 1; i < N-1; i++) {
int res = press(ans + map[2] + ans + map[3] + map[1] + ans + map[3] + map[2] + ans + map[3] + map[3]);
if (res == i) ans += map[1];
else if (res == i+1) ans += map[2];
else if (res == i+2) ans += map[3];
else abort();
}
// add last letter
if (press(ans + map[1]) == N) ans += map[1];
else if (press(ans + map[2]) == N) ans += map[2];
else ans += map[3];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |