Submission #1370036

#TimeUsernameProblemLanguageResultExecution timeMemory
1370036nedabekir05Dark Ride (EGOI25_darkride)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int query(string &s) {
    cout<<"?"<<s<<"\n"<<flush;
    int ans;
    cin>>ans;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(&cout);

    int N;
    cin >> N;
    int res[2]={-1,-1};
    int i=0; 
    if(query("100")==1){
        res[i]=0;
        i++;
    }
    if(query("010")==1){
        res[i]=1;
        i++;
    }
    if(query("001")==1){
        res[i]=2;
    }
    cout<<"! "<<res[0]<<" "<<res[1]<<"\n"<<flush;

    
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:19:14: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   19 |     if(query("100")==1){
      |              ^~~~~
In file included from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from Main.cpp:1:
/usr/include/c++/13/bits/basic_string.h:641:7: note:   after user-defined conversion: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with <template-parameter-2-1> = std::allocator<char>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  641 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
Main.cpp:4:19: note:   initializing argument 1 of 'int query(std::string&)'
    4 | int query(string &s) {
      |           ~~~~~~~~^
Main.cpp:23:14: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   23 |     if(query("010")==1){
      |              ^~~~~
/usr/include/c++/13/bits/basic_string.h:641:7: note:   after user-defined conversion: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with <template-parameter-2-1> = std::allocator<char>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  641 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
Main.cpp:4:19: note:   initializing argument 1 of 'int query(std::string&)'
    4 | int query(string &s) {
      |           ~~~~~~~~^
Main.cpp:27:14: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   27 |     if(query("001")==1){
      |              ^~~~~
/usr/include/c++/13/bits/basic_string.h:641:7: note:   after user-defined conversion: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with <template-parameter-2-1> = std::allocator<char>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  641 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
Main.cpp:4:19: note:   initializing argument 1 of 'int query(std::string&)'
    4 | int query(string &s) {
      |           ~~~~~~~~^