Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 128;
const int S = 62;
const char C[62] = { 
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

string q , ans;
vector<string> vec;

int cnt = 0;

int qry( void ) {
  cout << "? " << q << endl;
  int t;
  cin >> t;
  return t;
}

void Sort( void ) {
  sort( vec.begin() , vec.end() , []( string a , string b ) { return a.length() > b.length(); } );
}

string merge( string A , string B ) {
  auto a = A.begin() , b = B.begin();
  string res;
  while( a != A.end() && b != B.end() ) {
    q = res + *a;
    for( auto i = b ; i != B.end() ; ++i ) q += *i;
    if( qry() + q.length() == 128 )
      res += *a++;
    else res += b++;
  }
  while( a != A.end() ) res += *a++;
  while( b != B.end() ) res += *b++;
  return res;
}

int main( void ) {
  for( int i = 0 , x ; i < S ; ++i ) {
    q = string( N , C[i] );
    x = N - qry();
    if( x ) vec.push_back( string( x , C[i] ) );
  }
  Sort();
  while( vec.size() > 1 ) {
    string a = vec.back();
    vec.pop_back();
    string b = vec.back();
    vec.pop_back();
    vec.push_back( merge( a , b ) );
    Sort();
  }
  cout << "! " << vec[0] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'std::string merge(std::string, std::string)':
a.cc:34:14: error: no match for 'operator+=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >')
   34 |     else res += b++;
      |          ~~~~^~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1424:9: 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 _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1424 |         operator+=(const _Tp& __svt)
      |         ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1424:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)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 = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1424: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+=(const _Tp&) [with _Tp = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >]'
 1424 |         operator+=(const _Tp& __svt)
      |         ^~~~~~~~
a.cc:34:18:   required from here
   34 |     else res += b++;
      |                  ^~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1377: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>]'
 1377 |       operator+=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1377:38: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'const std::__cxx11::basic_string<char>&'
 1377 |       operator+=(const basic_string& __str)
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1387: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>]'
 1387 |       operator+=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1387:32: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'const char*'
 1387 |       operator+=(const _CharT* __s)
      |                  ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1397: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>]'
 1397 |       operator+=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1397:25: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'char'
 1397 |       operator+=(_CharT __c)
      |                  ~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1411: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>]'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1411:43: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'std::initializer_list<char>'
 1411 |       operator+=(initializer_list<_CharT> __l)
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~^~~