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 <iostream>
using namespace std;
int press(string s);
char a[] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n) {
a[0] = 'A'; a[1] = 'B'; a[2] = 'X'; a[3] = 'Y';
int h = 0;
if (press("AB")) {
if (press("A")) h = 0;
else h = 1;
}
else {
if (press("X")) h = 2;
else h = 3;
}
swap(a[h], a[3]);
string s = ""; s += a[3];
if (n == 1) return s;
for (int i = 2; i < n; i++) {
int h = press(s + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]);
h -= s.size();
if (h == 0) s += a[2];
else if (h == 1) s += a[0];
else s += a[1];
}
if (press(s + a[0]) == n) return s + a[0];
if (press(s + a[1]) == n) return s + a[1];
return s + a[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |