Submission #1316449

#TimeUsernameProblemLanguageResultExecution timeMemory
1316449haiduong2110Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"

using namespace std;

string guess_sequence(int n) {
    string s, ans;

    int ret = press("AB");
    if (ret == 2) ans += "AB";
    else if (ret == 1) {
        ret = press("A");
        if (ret == 1) ans += "A";
        else ans += "B";
    } else {
        ret = press("X");
        if (ret == 1) ans += "X";
        else ans += "Y";
    }

    if (ans.size() == n) return ans;

    vector<string> vec;
    if (ans[0] != 'A') vec.pb("A");
    if (ans[0] != 'B') vec.pb("B");
    if (ans[0] != 'X') vec.pb("X");
    if (ans[0] != 'Y') vec.pb("Y");
    

    while (ans.size() + 1 < n) {
        s = ans + vec[0] + ans + vec[1] + vec[0] + ans + vec[1] + vec[1] + ans + vec[1] + vec[2];
        
        int ret = press(s);
        if (ret == (int)ans.size()) ans += vec[2];
        if (ret == (int)ans.size() + 1) ans += vec[0];
        if (ret == (int)ans.size() + 2) ans += vec[1];
    }

    if (press(ans + vec[0]) == n) ans += vec[0];
    else if (press(ans + vec[1]) == n) ans += vec[1];
    else ans += vec[2];


    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:5: error: 'vector' was not declared in this scope
   22 |     vector<string> vec;
      |     ^~~~~~
combo.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "combo.h"
  +++ |+#include <vector>
    2 | 
combo.cpp:22:18: error: expected primary-expression before '>' token
   22 |     vector<string> vec;
      |                  ^
combo.cpp:22:20: error: 'vec' was not declared in this scope
   22 |     vector<string> vec;
      |                    ^~~