Submission #1311307

#TimeUsernameProblemLanguageResultExecution timeMemory
1311307tschav_Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
    string s1 = "ABACAXB";
    string s2(N, 'C');
    char init;
    int a1 = make_guess(s1);
    if(a1 == 2) init = 'A';
    if(a1 == 1) init = 'B';
    int a2 = make_guess(s2);
    if(a2) init = 'C';
    else init = 'Y';

    string S(N, init);
    string last = "";
    last += init;
    set<char> st;
    st.insert('A');
    st.insert('B');
    st.insert('X');
    st.insert('Y');
    st.erase(init);
    char c[3];
    int ptr = 0;
    for(auto &ch : st) {
        c[ptr++] = ch;
    }
    for(int i = 1; i+1 < N; i++) {
        string Q;
        Q += last;
        Q += c[0];
        Q += last;
        Q += c[1];
        Q += c[0];
        Q += last;
        Q += c[1];
        Q += c[1];
        Q += last;
        Q += c[1];
        Q += c[2];
        int res = make_guess(Q);
        if(res == last.size()+1){
            S[i] = c[0];
            last += c[0];
        }else if(res == last.size()+2){
            S[i] = c[1];
            last += c[1];
        }else{
            S[i] = c[2];
            last += c[2];
        }
    }

    Q = last + c[0];
    int res = make_guess(Q);
    if(res == last.size()+1){
        S[N-1] = c[0];
    }else{
        Q = last + c[1];
        res = make_guess(Q);
        if(res == last.size()+1){
            S[N-1] = c[1];
        }else{
            S[N-1] = c[2];
        }
    }

    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:14: error: 'make_guess' was not declared in this scope
    8 |     int a1 = make_guess(s1);
      |              ^~~~~~~~~~
combo.cpp:18:5: error: 'set' was not declared in this scope
   18 |     set<char> st;
      |     ^~~
combo.cpp:2:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
    1 | #include "combo.h"
  +++ |+#include <set>
    2 | using namespace std;
combo.cpp:18:9: error: expected primary-expression before 'char'
   18 |     set<char> st;
      |         ^~~~
combo.cpp:19:5: error: 'st' was not declared in this scope; did you mean 's2'?
   19 |     st.insert('A');
      |     ^~
      |     s2
combo.cpp:55:5: error: 'Q' was not declared in this scope
   55 |     Q = last + c[0];
      |     ^