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;
#define len(x) (int)(x).size()
std::string guess_sequence(int N) {
string a;
int x = press("AB");
if (x > 0) {
x = press("B");
if (x > 0) {
a = "B";
} else {
a = "A";
}
} else {
x = press("Y");
if (x > 0) {
a = "Y";
} else {
a = "X";
}
}
string r = "ABXY";
r.erase(r.begin() + r.find(a[0]));
// cout << r << endl;
for (int i = 0; i < N - 2; i++) {
string cur = a + r[1] + a + r[0] + r[1] + a + r[0] + r[0] + a + r[0] + r[2];
int y = press(cur);
if (y == len(a) + 1) {
a += r[1]; // only a + r[1] can make len(a) + 1
} else if (y == len(a) + 2) {
a += r[0]; // next char must be r[0]
} else {
a += r[2]; // last choice
}
}
string last = a + r[0] + a + r[1];
x = press(last);
if (x == len(a) + 1) {
last = a + r[0];
x = press(last);
if (x == len(a)) {
a += r[1];
} else {
a += r[0];
}
} else {
a += r[2];
}
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |