제출 #860522

#제출 시각아이디문제언어결과실행 시간메모리
860522Erhmee콤보 (IOI18_combo)C++14
컴파일 에러
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;
}

컴파일 시 표준 에러 (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");
      |                   ^~~~~~~~~~~~~