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 ans = "";
if (press("AB") >= 1) {
if (press("A")) {
ans = "A";
} else {
ans = "B";
}
} else {
if (press("X")) {
ans = "X";
} else {
ans = "Y";
}
}
set<char> st = {'A', 'B', 'X', 'Y'};
for (auto& c : st) {
if (ans[0] == c) {
st.erase(c);
break;
}
}
for (int i = 1; i < N - 1; i++) {
string guess = ans + *st.begin();
for (auto& c : st) {
guess += ans + *prev(st.end()) + c;
}
int tmp = press(guess);
if (tmp == (int) ans.length()) {
ans += *next(st.begin());
} else if (tmp == (int) ans.length() + 1) {
ans += *st.begin();
} else {
ans += *prev(st.end());
}
}
if ((int) ans.length() != N) {
if (press(ans + *st.begin()) == N) {
ans += *st.begin();
} else if (press(ans + *next(st.begin())) == N) {
ans += *next(st.begin());
} else {
ans += *prev(st.end());
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |