# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860522 | Erhmee | Combo (IOI18_combo) | C++14 | 0 ms | 0 KiB |
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 <string>
#include <vector>
using namespace std;
string guess_sequence(int N) {
vector<char> buttons = {'A', 'B', 'X', 'Y'};
string secret_string = "";
// Define a function to check if a given sequence appears in the secret string.
auto check_sequence = [&](string sequence) {
return press(secret_string + sequence) > secret_string.length();
};
for (int i = 0; i < N; ++i) {
bool found = false;
for (char button : buttons) {
if (secret_string.find(button) == string::npos) {
if (check_sequence(string(1, button))) {
secret_string += button;
found = true;
break;
}
}
}
if (!found) {
// Handle error, as you cannot find the next character in the secret string
throw runtime_error("Cannot find the next character in the secret string");
}
}
return secret_string;
}