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"
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
int n = N;
string res = "";
if (press("AB") > 0) {
if (press("A") > 0) res = "A";
else res = "B";
} else {
if (press("X") > 0) res = "X";
else res = "Y";
}
char st = res[0];
for (int i = 2; i <= n - 1; ++i) {
if (st == 'A') {
int x = press(res + "B" + res + "XY" + res +"XB" +res +"XX");
// cout << x << endl;
if (x == i) res += "B";
else if(x == i+1) res += "X";
else res += "Y";
} else if (st == 'B') {
int x = press(res + "A" + res + "XY" + res +"XA" +res +"XX");
if (x == i) res += "A";
else if(x == i+1) res += "X";
else res += "Y";
} else if (st == 'X') {
int x = press(res + "B" + res + "AY" + res +"AA" +res +"AB");
if (x == i) res += "B";
else if(x == i+1) res += "A";
else res += "Y";
} else {
int x = press(res + "B" + res + "AX" + res +"AA" +res +"AB");
if (x == i) res += "B";
else if(x == i+1) res += "A";
else res += "X";
}
// cout << res << endl;
}
if (n > 1) {
if (st == 'A') {
if(press(res +"B") == n) res = res +"B";
else if (press(res + "X") == n) res = res +"X";
else res = res +"Y";
} else if (st == 'B') {
if(press(res +"A") == n) res = res +"A";
else if (press(res + "X") == n) res = res +"X";
else res = res +"Y";
} else if (st == 'X') {
if(press(res +"A") == n) res = res +"A";
else if (press(res + "B") == n) res = res +"B";
else res = res +"Y";
} else {
if(press(res +"A") == n) res = res +"A";
else if (press(res + "B") == n) res = res +"B";
else res = res +"X";
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |