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>
using namespace std;
int press(string p);
vector < char > aux;
string first_char() {
string s = "AB";
if (press(s)) {
s = "A";
if (press(s)) {
aux = {'B', 'X', 'Y'};
return s;
}
aux = {'A', 'X', 'Y'};
return "B";
}
s = "X";
if (press(s)) {
aux = {'A', 'B', 'Y'};
return s;
}
aux = {'A', 'B', 'X'};
return "Y";
}
string guess_sequence(int N) {
string s = first_char();
for (int i = 2; i < N; ++i) {
string q = s + aux[0] + aux[0] + s + aux[0] + aux[1] + s + aux[0] + aux[2] + s + aux[1];
int ans = press(q);
if (ans == i + 1) s += aux[0];
else if (ans == i) s += aux[1];
else s += aux[2];
}
if (N > 1) {
s += aux[0];
if (press(s) == N) return s;
s[N - 1] = aux[1];
if (press(s) == N) return s;
s[N - 1] = aux[2];
return s;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |