Submission #1196429

#TimeUsernameProblemLanguageResultExecution timeMemory
1196429ffeyyaae_Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence( int N ) { string s = ""; string a = "ABXY"; vector<string> bt; if( press("A") ) s += "A"; else if( press("B") ) s += "B"; else if( press("X") ) s += "X"; else s += "Y"; if( N == 1 ) return s; for( auto c : a ) if( s[0] != c ) bt.push_back( c ); for( int i=1;i<N;i++ ) { string tp = s+bt[0] + s+bt[1]+bt[0] + s+bt[1]+bt[1] + s+bt[1]+bt[2]; int sz = sizeof(s); if( press(tp) == sz+1 ) s += bt[0]; else if( press(tp) == sz+2 ) s += bt[1]; else s += bt[2]; } if( press(s+bt[0]) ) s += bt[0]; else if( press(s+bt[1]) ) s += bt[1]; else s += bt[2]; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:51: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::push_back(char&)'
   16 |     for( auto c : a ) if( s[0] != c ) bt.push_back( c );
      |                                       ~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::value_type = std::__cxx11::basic_string<char>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'char' to 'const value_type&' {aka 'const std::__cxx11::basic_string<char>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::value_type = std::__cxx11::basic_string<char>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'char' to 'std::vector<std::__cxx11::basic_string<char> >::value_type&&' {aka 'std::__cxx11::basic_string<char>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~