Submission #1032473

#TimeUsernameProblemLanguageResultExecution timeMemory
1032473ThommyDBCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; string guess_sequence(int N) { string p = ""; if(press("AB")>=1){ if(press("A") >= 1) p+="A"; else p+="B"; } else{ if(press("X") >= 1) p+="X"; else p+="Y"; } if(N==1)return p; vector<char> a; for(auto u : "ABXY"){ if(u!=p[0]) a.push_back(u); } for(int i = 1; i<N-1; i++){ string s = ""; s += a; s += a[0]; s += a; s += a[1]; s += a[0]; s += a; s += a[1]; s += a[1]; s += a; s += a[1]; s += a[2]; int v = press(s); if(v == p.length() +1) p+=a[0]; else if(v==p.length()+2) p+=a[1]; else p+=a[2]; } if(press(p+a[0]) == N) p+=a[0]; else if(press(p+a[1])==N) p+=a[1]; else p+=a[2]; return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:7: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::vector<char>')
   25 |     s += a; s += a[0]; s += a; s += a[1]; s += a[0]; s += a; s += a[1]; s += a[1]; s += a; s += a[1]; s += a[2];
      |     ~~^~~~
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:25: note:   no known conversion for argument 1 from 'std::vector<char>' to 'char'
 1157 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'std::vector<char>' to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/type_traits: In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/10/bits/basic_string.h:117:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using _If_sv = std::enable_if_t<std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value, _Res> [with _Tp = std::vector<char>; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
/usr/include/c++/10/bits/basic_string.h:1182:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::operator+=<_Tp>(const _Tp&) [with _Tp = std::vector<char>]'
combo.cpp:25:10:   required from here
/usr/include/c++/10/type_traits:2554:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2554 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
combo.cpp:25:26: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::vector<char>')
   25 |     s += a; s += a[0]; s += a; s += a[1]; s += a[0]; s += a; s += a[1]; s += a[1]; s += a; s += a[1]; s += a[2];
      |                        ~~^~~~
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:25: note:   no known conversion for argument 1 from 'std::vector<char>' to 'char'
 1157 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'std::vector<char>' to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
combo.cpp:25:56: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::vector<char>')
   25 |     s += a; s += a[0]; s += a; s += a[1]; s += a[0]; s += a; s += a[1]; s += a[1]; s += a; s += a[1]; s += a[2];
      |                                                      ~~^~~~
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:25: note:   no known conversion for argument 1 from 'std::vector<char>' to 'char'
 1157 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'std::vector<char>' to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
combo.cpp:25:86: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'std::vector<char>')
   25 |     s += a; s += a[0]; s += a; s += a[1]; s += a[0]; s += a; s += a[1]; s += a[1]; s += a; s += a[1]; s += a[2];
      |                                                                                    ~~^~~~
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1139:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1139 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1139:38: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const std::__cxx11::basic_string<char>&'
 1139 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/bits/basic_string.h:1148:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1148 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1148:32: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const char*'
 1148 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1157:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1157 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1157:25: note:   no known conversion for argument 1 from 'std::vector<char>' to 'char'
 1157 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1170:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1170:43: note:   no known conversion for argument 1 from 'std::vector<char>' to 'std::initializer_list<char>'
 1170 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(const _Tp&) [with _Tp = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1182 |  operator+=(const _Tp& __svt)
      |  ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:1182:2: note:   template argument deduction/substitution failed:
combo.cpp:28:10: 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(v == p.length() +1) p+=a[0];
      |        ~~^~~~~~~~~~~~~~~~
combo.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     else if(v==p.length()+2) p+=a[1];
      |             ~^~~~~~~~~~~~~~