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;
string guess_sequence(int n) {
string s = "";
string choice = "ABXY";
if (press(choice.substr(0, 2))) {
if (press(string(1, choice[0]))) s += choice[0];
else s += choice[1];
} else {
if (press(string(1, choice[2]))) s += choice[2];
else s += choice[3];
}
int idx = choice.find(s[0]);
choice.erase(choice.begin() + idx);
for (int i = 1; i < n - 1; i++) {
string ask = s + choice[0] + s + choice[1] + choice[0] + s + choice[1] + choice[1] + s + choice[1] + choice[2];
int res = press(ask);
if (res == i) s += choice[2];
else if (res == i + 1) s += choice[0];
else s += choice[1];
}
if (n == 1) return s;
if (press(s + choice[0]) == n) s += choice[0];
else if (press(s + choice[1]) == n) s += choice[1];
else s += choice[2];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |