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;
vector<char> ca {'A', 'B', 'X', 'Y'}, cand;
string guess_sequence (int n) {
string ans;
for (int i = 0; i < 4; ++i) {
ans = ca[i];
if (i == 3 || press(ans)) {
ca.erase(ca.begin() + i);
cand = ca;
break;
}
}
for (int i = 1; i < n - 1; ++i) {
string ask = ans + ca[0] + ans + ca[1] + ca[0] + ans + ca[1] + ca[1] + ans + ca[1] + ca[2];
int x = press(ask);
if (x == i) {
ans += ca[2];
}
else if (x == i + 1) {
ans += ca[0];
}
else {
ans += ca[1];
}
}
return n == 1 ? ans : ans + (press(ans + ca[0]) == n ? ca[0] : press(ans + ca[1]) == n ? ca[1] : ca[2]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |