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 cs = "ABXY";
string guess_sequence(int n) {
int first = -1;
string ans;
if (press("AB")) {
if (press("A")) ans = "A", first = 0;
else ans = "B", first = 1;
} else {
if (press("X")) ans = "X", first = 2;
else ans = "Y", first = 3;
}
if (n == 1) return ans;
assert(first != -1);
for (int i = 0; i < n - 2; ++i) {
string q = "";
int cnt = 0;
for (int j = 0; j < 4; ++j) if (j != first) {
if (cnt == 1) {
q += ans + cs[j];
} else if (cnt == 2) {
for (int k = 0; k < 4; ++k) if (k != first) {
q += ans + cs[j] + cs[k];
}
}
++cnt;
}
int cur = press(q);
cnt = ans.size();
for (int j = 0; j < 4; ++j) if (j != first) {
if (cnt == cur) {
ans += cs[j];
}
++cnt;
}
}
if (press(ans + "A" + ans + "B") == n) {
if (press(ans + "A") == n) return ans + "A";
else return ans + "B";
} else {
if (press(ans + "X") == n) return ans + "X";
else return ans + "Y";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |