Submission #245713

#TimeUsernameProblemLanguageResultExecution timeMemory
245713uacoder123Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; string guess_sequence(int N) { int n=N; string s; vector<string> v={"A","B","C","D"}; if(press("AB")==1) { if(press("A")) s+="A"; else s+="B"; } else { if(press("X")) s+="X"; else s+="Y"; } v.erase(s); v.pb(s); for(int i=0;i<n-1;++i) { int x=press(s+v[0]+s+v[1]+v[0]+s+v[1]+v[1]+s+v[1]+v[2]); if(x==s.size()+1) s+=v[0]; else if(x==s.size()+2) s+=v[1]; else s+=v[2]; } if(press(s+"A"+s+"B")==s.size()+1) { if(press(s+"A")==s.size()+1) s+="A"; else s+="B"; } else { if(press(s+"X")==s.size()+1) s+="X"; else s+="Y"; } return(s); }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:6: error: 'press' was not declared in this scope
   22 |   if(press("AB")==1)
      |      ^~~~~
combo.cpp:36:12: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::erase(std::string&)'
   36 |   v.erase(s);
      |            ^
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:1:
/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 = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::__cxx11::basic_string<char> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::__cxx11::basic_string<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 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::vector<std::__cxx11::basic_string<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 = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::__cxx11::basic_string<char> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::__cxx11::basic_string<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:40:11: error: 'press' was not declared in this scope
   40 |     int x=press(s+v[0]+s+v[1]+v[0]+s+v[1]+v[1]+s+v[1]+v[2]);
      |           ^~~~~
combo.cpp:41:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     if(x==s.size()+1)
      |        ~^~~~~~~~~~~~
combo.cpp:43:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     else if(x==s.size()+2)
      |             ~^~~~~~~~~~~~
combo.cpp:48:6: error: 'press' was not declared in this scope
   48 |   if(press(s+"A"+s+"B")==s.size()+1)
      |      ^~~~~