Submission #770712

#TimeUsernameProblemLanguageResultExecution timeMemory
770712AtinaRCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { char first; int f=press("AB"); if(f>=1) { f=press("A"); if(f>=1) { first='A'; } else { first='B'; } } else { f=press("X"); if(f>=1) { first='X'; } else first='Y'; } string res=""; res+=first; char possible[3]; if(first=='X') { possible[0]='A'; possible[1]='B'; possible[2]='Y'; } else if(first=='Y') { possible[0]='A'; possible[1]='B'; possible[2]='X'; } else if(first=='A') { possible[0]='X'; possible[1]='B'; possible[2]='Y'; } else if(first=='B') { possible[0]='A'; possible[1]='X'; possible[2]='Y'; } while(res.size()<N) { int tmp; string A=res+possible[0]; string B=res+possible[1]; string C=res+possible[2]; tmp=press(A); if(tmp==A.size()) { res=A; continue; } tmp=press(B); if(tmp==B.size()) { res=B; continue; } res=C; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
   28 |     string res="";
      |     ^~~~~~
      |     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:29:5: error: 'res' was not declared in this scope
   29 |     res+=first;
      |     ^~~
combo.cpp:58:15: error: expected ';' before 'A'
   58 |         string A=res+possible[0];
      |               ^~
      |               ;
combo.cpp:59:15: error: expected ';' before 'B'
   59 |         string B=res+possible[1];
      |               ^~
      |               ;
combo.cpp:60:15: error: expected ';' before 'C'
   60 |         string C=res+possible[2];
      |               ^~
      |               ;
combo.cpp:61:19: error: 'A' was not declared in this scope
   61 |         tmp=press(A);
      |                   ^
combo.cpp:67:19: error: 'B' was not declared in this scope
   67 |         tmp=press(B);
      |                   ^
combo.cpp:73:13: error: 'C' was not declared in this scope
   73 |         res=C;
      |             ^