Submission #110941

#TimeUsernameProblemLanguageResultExecution timeMemory
110941CodeKrackerCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include<bits/stdc++.h> #define FOR(i,a,b) for (int i = a; i < b; i++) #define FORD(i,a,b) for (int i = a; i >= b; i--) using namespace std; char gf(){ int c = press("AB"); if(c > 0){ int a = press("A"); if(a){ return 'A'; }else{ return 'B'; } }else{ int x = press("X"); if(x){ return 'X'; }else{ return 'Y'; } } } char gl(string ans,vector<char> vec){ int c = press(ans+vec[0]); if(c == ans.length()+1){ return vec[0]; } c = press(ans+vec[1]); if(c == ans.length()+1){ return vec[1]; } return vec[2]; } std::string guess_sequence(int n) { char f = gf(); vector<char> rem; rem.push_back('A'); rem.push_back('B'); rem.push_back('X'); rem.push_back('Y'); rem.erase(f); string ans = ""; ans += f; FOR(i,1,n-1){ string cur = ans+rem[0]+ans+rem[1]+rem[0]+ans+rem[1]+rem[1]+ans+rem[1]+rem[2]; int c = press(cur); if(c == ans.length()){ ans += rem[2]; }else if(c == ans.length()+1){ ans += rem[0]; }else{ ans += rem[1]; } } char l = gl(ans,rem); ans += l; return ans; }

Compilation message (stderr)

combo.cpp: In function 'char gl(std::string, std::vector<char>)':
combo.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(c == ans.length()+1){
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(c == ans.length()+1){
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:14: error: no matching function for call to 'std::vector<char>::erase(char&)'
   45 |   rem.erase(f);
      |              ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from combo.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::iterator = std::vector<char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<char>::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:28: note:   no known conversion for argument 1 from 'char' to 'std::vector<char>::const_iterator'
 1430 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::iterator = std::vector<char>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<char>::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:7: note:   candidate expects 2 arguments, 1 provided
combo.cpp:51:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if(c == ans.length()){
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     }else if(c == ans.length()+1){
      |              ~~^~~~~~~~~~~~~~~~~