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);
string guess_sequence(int n) {
vector<char> v = {'A', 'B', 'X', 'Y'};
string ret;
if (press("AB")) {
if (press("A")) {
ret += 'A';
swap(v[0], v[3]);
}
else {
ret += 'B';
swap(v[1], v[3]);
}
}
else {
if (press("X")) {
ret += 'X';
swap(v[2], v[3]);
}
else {
ret += 'Y';
// swap(v[3], v[3]);
}
}
while ((int) ret.size() < n - 1) {
string tmp = ret + v[0];
for (int i = 0; i < 3; i++) {
tmp += ret + v[1] + v[i];
}
int p = press(tmp);
if (p == (int) ret.size() + 1) {
ret += v[0];
}
else if (p == (int) ret.size() + 2) {
ret += v[1];
}
else {
ret += v[2];
}
}
if (n > 1) {
if (press(ret + v[0]) == n) {
ret += v[0];
}
else if (press(ret + v[1]) == n) {
ret += v[1];
}
else {
ret += v[2];
}
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |