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;
}
}
if (n == 1) {
return ans;
}
for (int i = 1; i < n - 1; ++i) {
for (char c : cand) {
int x = press(ans + c + c) - i;
if (x) {
ans += c;
if (x == 1) {
cand = ca;
cand.erase(find(cand.begin(), cand.end(), c));
}
else {
cand = {c};
}
break;
}
}
}
return ans + (press(ans + cand[0]) == n ? cand[0] : cand[1]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |