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) {
set<char> X = {'A', 'B', 'X', 'Y'};
string s = "";
for (auto it = X.begin(); it != X.end(); it++) {
int x = press(s + *it);
if (x != 0) {
s += *it;
X.erase(it);
break;
}
}
if (s == "") {
return s;
}
int prev = 1;
bool ok = true;
string e = "";
while (ok) {
ok = false;
int sz = (int) s.size();
if (2 * sz - 1 <= N) {
int x = press(s + e);
if (x > prev) {
for (int j = 0; j < x - prev; j++) {
s += e[j];
}
prev = x;
ok = true;
continue;
}
}
for (auto it = X.begin(); it != X.end(); it++) {
string poss = s + *it;
int d = N - sz;
string t = "";
for (int j = 0; j < d; j++) {
t += *it;
}
int x = press(s + t);
if (x > prev) {
for (int j = 0; j < x - prev; j++) {
e += *it;
s += *it;
}
ok = true;
prev = x;
break;
}
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |