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;
#define in(i) cin >> i
#define out(o) cout << o
string guess_sequence(int N) {
string ans = "";
int first = press("AB");
vector<string> left;
if (first) {
first = press("A");
if (first) ans += "A", left.push_back("B"), left.push_back("X"), left.push_back("Y");
else ans += "B", left.push_back("A"), left.push_back("X"), left.push_back("Y");
} else {
first = press("X");
if (first) ans += "X", left.push_back("B"), left.push_back("A"), left.push_back("Y");
else ans += "Y", left.push_back("B"), left.push_back("X"), left.push_back("A");
}
for (int i = 0; i < N - 2; i++) {
string inp = (ans + left[0]) + (ans + left[1] + left[0]) + (ans + left[1] + left[1]) + (ans + left[1] + left[2]);
int res = press(inp);
if (res == i + 1) {
ans += left[2];
} else if (res == i + 2) {
ans += left[0];
} else {
ans += left[1];
}
}
if (N != 1) {
int last = press(ans + left[0]);
if (last == N) ans += left[0];
else {
last = press(ans + left[1]);
if (last == N) ans += left[1];
else ans += left[2];
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |