Submission #1111406

#TimeUsernameProblemLanguageResultExecution timeMemory
1111406epicci23Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;

vector<char> v;

int ask(string s,int ekle){
  s.push_back(v[ekle]);
  return press(s);
}


string guess_sequence(int n){
  string res="";
   
  if(press("A")==1){
  	res.push_back('A');
  	v.push_back('B');
  	v.push_back('X');
  	v.push_back('Y');
  }
  else{
    v.push_back('A');
    if(press("B")==1){
      res.push_back('B');
      v.push_back('X');
  	  v.push_back('Y');
    }
    else{
      v.push_back('B');
      if(press("X")==1){
      	res.push_back("X");
      	v.push_back("Y");
      }
      else{
        res.push_back("Y");
        v.push_back("X");
      }
    }
  }


  for(int i=1;i<n;i++){
  	bool ok=0;
  	for(int j=0;j<2;j++){
  	  if(ask(res,j)==i+1){
        res.push_back(v[j]);
        ok=1;
        break;
  	  }
  	}
  	if(!ok) res.push_back(v.back());
  }

  return res;
}


/*void _(){
	
}

int32_t main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tc=1;//cin >> tc;
  while(tc--) _();
  return 0;
}*/

Compilation message (stderr)

combo.cpp: In function 'int ask(std::string, int)':
combo.cpp:11:10: error: 'press' was not declared in this scope
   11 |   return press(s);
      |          ^~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:6: error: 'press' was not declared in this scope; did you mean 'res'?
   18 |   if(press("A")==1){
      |      ^~~~~
      |      res
combo.cpp:34:22: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   34 |        res.push_back("X");
      |                      ^~~
      |                      |
      |                      const char*
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1320:24: note:   initializing argument 1 of 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1320 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~
combo.cpp:35:23: error: no matching function for call to 'push_back(const char [2])'
   35 |        v.push_back("Y");
      |                       ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = char]' (near match)
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:35:20: error: invalid conversion from 'const char*' to 'std::vector<char>::value_type' {aka 'char'} [-fpermissive]
   35 |        v.push_back("Y");
      |                    ^~~
      |                    |
      |                    const char*
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = char]' (near match)
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:35:20: error: invalid conversion from 'const char*' to 'std::vector<char>::value_type' {aka 'char'} [-fpermissive]
   35 |        v.push_back("Y");
      |                    ^~~
      |                    |
      |                    const char*
combo.cpp:38:23: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   38 |         res.push_back("Y");
      |                       ^~~
      |                       |
      |                       const char*
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1320:24: note:   initializing argument 1 of 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1320 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~
combo.cpp:39:24: error: no matching function for call to 'push_back(const char [2])'
   39 |         v.push_back("X");
      |                        ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = char]' (near match)
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:39:21: error: invalid conversion from 'const char*' to 'std::vector<char>::value_type' {aka 'char'} [-fpermissive]
   39 |         v.push_back("X");
      |                     ^~~
      |                     |
      |                     const char*
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = char]' (near match)
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   conversion of argument 1 would be ill-formed:
combo.cpp:39:21: error: invalid conversion from 'const char*' to 'std::vector<char>::value_type' {aka 'char'} [-fpermissive]
   39 |         v.push_back("X");
      |                     ^~~
      |                     |
      |                     const char*