Submission #476346

#TimeUsernameProblemLanguageResultExecution timeMemory
476346ponytailCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    string S;
    if(press("A")) {
        S += "A";
    }
    else if(press("B")) {
        S += "B";
    }
    else if(press("X")) {
        S += "X";
    }
    else {
        S += "Y";
    }
    string W = "ABXY", T;
    for(int i=0; i<4; i++) {
        if(S[0] != W[i]) T += W[i];
    }
    for(int i=1; i<N-1; i++) {
        string one = S + T[0];
        string q;
        for(int j=0; j<3; j++) {
            q += one;
            q += T[j];
        }
        q += S;
        q += T[1];
        q += S[0];
        int res = press(q);
        if(res == i + 2) S += T[0];
        else if(res == i + 1) S += T[1];
        else S += T[2];
    }
    if(press(S + T[0]) == N) S += T[0];
    else if(press(S + T[1]) == N) S += T[1];
    else S += T[2];
    cout << S << "\n";
    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:5: error: 'string' was not declared in this scope
    4 |     string S;
      |     ^~~~~~
combo.cpp:4:5: note: suggested alternatives:
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:6:9: error: 'S' was not declared in this scope
    6 |         S += "A";
      |         ^
combo.cpp:9:9: error: 'S' was not declared in this scope
    9 |         S += "B";
      |         ^
combo.cpp:12:9: error: 'S' was not declared in this scope
   12 |         S += "X";
      |         ^
combo.cpp:15:9: error: 'S' was not declared in this scope
   15 |         S += "Y";
      |         ^
combo.cpp:17:11: error: expected ';' before 'W'
   17 |     string W = "ABXY", T;
      |           ^~
      |           ;
combo.cpp:19:12: error: 'S' was not declared in this scope
   19 |         if(S[0] != W[i]) T += W[i];
      |            ^
combo.cpp:19:20: error: 'W' was not declared in this scope
   19 |         if(S[0] != W[i]) T += W[i];
      |                    ^
combo.cpp:19:26: error: 'T' was not declared in this scope
   19 |         if(S[0] != W[i]) T += W[i];
      |                          ^
combo.cpp:22:15: error: expected ';' before 'one'
   22 |         string one = S + T[0];
      |               ^~~~
      |               ;
combo.cpp:23:15: error: expected ';' before 'q'
   23 |         string q;
      |               ^~
      |               ;
combo.cpp:25:13: error: 'q' was not declared in this scope
   25 |             q += one;
      |             ^
combo.cpp:25:18: error: 'one' was not declared in this scope; did you mean 'clone'?
   25 |             q += one;
      |                  ^~~
      |                  clone
combo.cpp:26:18: error: 'T' was not declared in this scope
   26 |             q += T[j];
      |                  ^
combo.cpp:28:9: error: 'q' was not declared in this scope
   28 |         q += S;
      |         ^
combo.cpp:28:14: error: 'S' was not declared in this scope
   28 |         q += S;
      |              ^
combo.cpp:29:14: error: 'T' was not declared in this scope
   29 |         q += T[1];
      |              ^
combo.cpp:36:14: error: 'S' was not declared in this scope
   36 |     if(press(S + T[0]) == N) S += T[0];
      |              ^
combo.cpp:36:18: error: 'T' was not declared in this scope
   36 |     if(press(S + T[0]) == N) S += T[0];
      |                  ^
combo.cpp:39:5: error: 'cout' was not declared in this scope
   39 |     cout << S << "\n";
      |     ^~~~
combo.cpp:39:13: error: 'S' was not declared in this scope
   39 |     cout << S << "\n";
      |             ^