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 S = "", q;
int x;
if (press("AB") >= 1) {
if (press("A") == 1) {
S += 'A';
} else {
S += 'B';
}
} else {
if (press("X") == 1) {
S += 'X';
} else {
S += 'Y';
}
}
if (N == 1)
return S;
int sz = 1;
for(int i = 1; i < N-1; i++, sz++) {
if (S[0] == 'A') {
q = S + "B" + S + "XB" + S + "XX" + S + "XY";
x = press(q);
if (x == sz) {
S += "Y";
} else if (x == sz + 1) {
S += "B";
} else {
S += "X";
}
} else if (S[0] == 'B') {
q = S + "A" + S + "XA" + S + "XX" + S + "XY";
x = press(q);
if (x == sz) {
S += "Y";
} else if (x == sz + 1) {
S += "A";
} else {
S += "X";
}
} else if (S[0] == 'X') {
q = S + "A" + S + "BA" + S + "BB" + S + "BY";
x = press(q);
if (x == sz) {
S += "Y";
} else if (x == sz + 1) {
S += "A";
} else {
S += "B";
}
} else {
q = S + "A" + S + "XA" + S + "XB" + S + "XX";
x = press(q);
if (x == sz) {
S += "B";
} else if (x == sz + 1) {
S += "A";
} else {
S += "X";
}
}
}
if (S[0] != 'A') {
q = S + "A";
x = press(q);
if (x == N) return q;
}
if (S[0] != 'B') {
q = S + "B";
x = press(q);
if (x == N) return q;
}
if (S[0] != 'X') {
if (S[0] == 'Y') {
S += 'X';
return S;
}
q = S + "X";
x = press(q);
if (x == N) return q;
}
S += "Y";
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |