Submission #911376

#TimeUsernameProblemLanguageResultExecution timeMemory
911376TurcavidCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h"
 
std::string guess_sequence(int N)
{
    vector<char> v;
    v.push_back('A');
    v.push_back('B');
    v.push_back('X');
    v.push_back('Y');
    int del=4;
    string sus="";
    for(int i=0; i<3; i++)
    {
        sus.clear();
        sus.push_back(v[i]);
        if(press(sus) == 1)
            del=i;
    }
    string ans="";
    ans+=v[del];
    v.erase(v.begin()+del);
    for(int i=2; i<=N-1; i++)
    {
        string qr="";
        qr+=(ans+v[1]);
        qr+=(ans+v[2]+v[0]);
        qr+=(ans+v[2]+v[1]);
        qr+=(ans+v[2]+v[2]);
        cout<<qr<<'\n';
        int val=press(qr);
        if(val == i-1)
            ans+=v[0];
        if(val == i)
            ans+=v[1];
        if(val == i+1)
            ans+=v[2];
    }
    for(int i=0; i<3; i++)
    {
        string qr=ans;
        qr+=v[i];
        if(press(qr) == N)
            return qr;
    }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:5:5: error: 'vector' was not declared in this scope
    5 |     vector<char> v;
      |     ^~~~~~
combo.cpp:5:12: error: expected primary-expression before 'char'
    5 |     vector<char> v;
      |            ^~~~
combo.cpp:6:5: error: 'v' was not declared in this scope
    6 |     v.push_back('A');
      |     ^
combo.cpp:11:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
   11 |     string sus="";
      |     ^~~~~~
      |     std::string
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' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
combo.cpp:14:9: error: 'sus' was not declared in this scope
   14 |         sus.clear();
      |         ^~~
combo.cpp:19:11: error: expected ';' before 'ans'
   19 |     string ans="";
      |           ^~~~
      |           ;
combo.cpp:20:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |     ans+=v[del];
      |     ^~~
      |     abs
combo.cpp:24:15: error: expected ';' before 'qr'
   24 |         string qr="";
      |               ^~~
      |               ;
combo.cpp:25:9: error: 'qr' was not declared in this scope
   25 |         qr+=(ans+v[1]);
      |         ^~
combo.cpp:29:9: error: 'cout' was not declared in this scope
   29 |         cout<<qr<<'\n';
      |         ^~~~
combo.cpp:40:15: error: expected ';' before 'qr'
   40 |         string qr=ans;
      |               ^~~
      |               ;
combo.cpp:41:9: error: 'qr' was not declared in this scope
   41 |         qr+=v[i];
      |         ^~
combo.cpp:44:5: error: expected '}' at end of input
   44 |     }
      |     ^
combo.cpp:4:1: note: to match this '{'
    4 | {
      | ^