Submission #485493

#TimeUsernameProblemLanguageResultExecution timeMemory
485493JooCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; /*int press(string p){ cout << p << "\n"; int x; cin >> x; return x; }*/ string guess_sequence(int N){ string str; vector<char> a = {'A', 'B', 'X', 'Y'}; if(press("AB") == 0){ ///either x or y if(press("X") == 1){ str += 'X'; a.erase(a.begin()+2); }else{ str += 'Y'; a.erase(a.begin()+3); } }else{ ///either a or b if(press("A") == 1){ str += 'A'; a.erase(a.begin()); }else{ str += 'B'; a.erase(a.begin()+1); } } for(int i = 2; i < N; i++){ string tmp = str + a[1] + str + a[2] + a[0] + str + a[2] + a[1] + str + a[2] + a[2]; int res = press(tmp); if(res == str.size()){ ///got nothing new str += a[0]; }else if(res == str.size()+1){ str += a[1]; }else{ str += a[2]; } } if(press(str+a[0]) == N){ str += a[0]; }else if(press(str+a[1]) == N){ str += a[1]; }else{ str += a[2]; } return str; } /* int main(void){ cout << guess_sequence(5) << "\n"; return 0; } */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:8: error: 'press' was not declared in this scope
   13 |     if(press("AB") == 0){ ///either x or y
      |        ^~~~~
combo.cpp:33:19: error: 'press' was not declared in this scope; did you mean 'res'?
   33 |         int res = press(tmp);
      |                   ^~~~~
      |                   res
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(res == str.size()){ ///got nothing new
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         }else if(res == str.size()+1){
      |                  ~~~~^~~~~~~~~~~~~~~
combo.cpp:44:8: error: 'press' was not declared in this scope
   44 |     if(press(str+a[0]) == N){
      |        ^~~~~