Submission #413584

#TimeUsernameProblemLanguageResultExecution timeMemory
413584timmyfengCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

#include "combo.h"

string guess_sequence(int n) {
    string ans;
    if (press("AB") > 0) {
        ans = press("A") > 0 ? "A" : "B";
    } else {
        ans = press("X") > 0 ? "X" : "Y";
    }

    string buttons = "ABXY";
    buttons.erase(find(buttons.begin(), buttons.end(), ans[0]));

    for (int i = 1; i < n - 1; ++i) {
        string ask = ans + buttons[1];
        for (int j = 0; j < 3; ++j) {
            ask += ans + buttons[2] + buttons[j];
        }

        int res = press(ask);

        for (int j = 0; j < 3; ++j) {
            if (res == i + j) {
                ans += buttons[j];
            }
        }
    }

    for (int i = 0; i < 2; ++i) {
        if (press(ans + button[i]) == n) {
            return ans + button[i];
        }
    }

    return ans + button[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:25: error: 'button' was not declared in this scope; did you mean 'buttons'?
   33 |         if (press(ans + button[i]) == n) {
      |                         ^~~~~~
      |                         buttons
combo.cpp:38:18: error: 'button' was not declared in this scope; did you mean 'buttons'?
   38 |     return ans + button[2];
      |                  ^~~~~~
      |                  buttons