Submission #860522

#TimeUsernameProblemLanguageResultExecution timeMemory
860522ErhmeeCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#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; }

Compilation message (stderr)

combo.cpp: In lambda function:
combo.cpp:11:16: error: 'press' was not declared in this scope
   11 |         return press(secret_string + sequence) > secret_string.length();
      |                ^~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:19: error: 'runtime_error' was not declared in this scope
   27 |             throw runtime_error("Cannot find the next character in the secret string");
      |                   ^~~~~~~~~~~~~