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 p); /*{
int x;
cout << p << endl;
cin >> x;
return x;
}*/
string guess_sequence(int n) {
string s;
int tmp;
if (press("AB")) {
if (press("A") == 1) s = "A";
else s = "B";
} else {
if (press("X") == 1) s = "X";
else s = "Y";
}
for (int i = 2; i < n; i++) {
if (s[0] == 'A') {
tmp = press(s+"B"+s+"XB"+s+"XX"+s+"XY");
if (tmp == i-1) s += "Y";
else if (tmp == i) s += "B";
else s += "X";
} else if (s[0] == 'B') {
tmp = press(s+"A"+s+"XA"+s+"XX"+s+"XY");
if (tmp == i-1) s += "Y";
else if (tmp == i) s += "A";
else s += "X";
} else if (s[0] == 'X') {
tmp = press(s+"A"+s+"BA"+s+"BB"+s+"BY");
if (tmp == i-1) s += "Y";
else if (tmp == i) s += "A";
else s += "B";
} else {
tmp = press(s+"A"+s+"BA"+s+"BB"+s+"BX");
if (tmp == i-1) s += "X";
else if (tmp == i) s += "A";
else s += "B";
}
}
if (s[0] == 'A') {
if (press(s+"B") == n) s += "B";
else if (press(s+"X") == n) s += "X";
else s += "Y";
} else if (s[0] == 'B') {
if (press(s+"A") == n) s += "A";
else if (press(s+"X") == n) s += "X";
else s += "Y";
} else if (s[0] == 'X') {
if (press(s+"A") == n) s += "A";
else if (press(s+"B") == n) s += "B";
else s += "Y";
} else {
if (press(s+"A") == n) s += "A";
else if (press(s+"B") == n) s += "B";
else s += "X";
}
return s;
}
/*int main() {
int n;
cin >> n;
cout << guess_sequence(n) << endl;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |