Submission #835314

#TimeUsernameProblemLanguageResultExecution timeMemory
835314mousebeaverCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

std::string guess_sequence(int N) 
{
    vector<string> a(0);
    string prefix = "";

    if(press("AB") == 1)
    {
        if(press("A") == 1)
        {
            a = {"B", "X", "Y"};
            prefix = "A";
        }
        else
        {
            a = {"A", "X", "Y"};
            prefix = "B";
        }
    }
    else
    {
        if(press("X") == 1)
        {
            a = {"B", "A", "Y"};
            prefix = "X";
        }
        else
        {
            a = {"A", "X", "B"};
            prefix = "Y";
        }
    }
    if(N == 1)
    {
        return prefix;
    }

    while((int) prefix.length() < N-1)
    {
        string q = prefix + a[1] + prefix + a[2] + a[0] + prefix + a[2] + a[1] + prefix + a[2] + a[2];
        int res = press(q);
        if(res == (int) prefix.length())
        {
            prefix += a[0];
        }
        else if(res == (int) prefix.length()+1)
        {
            prefix += a[1];
        }
        else
        {
            prefix += a[2];
        }
    }

    index = 0;
    while(press(prefix+a[index]) < N)
    {
        index++;
    }
    prefix += a[index];

    return prefix;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:13: error: overloaded function with no contextual type information
   59 |     index = 0;
      |             ^
combo.cpp:60:25: error: no match for 'operator[]' (operand types are 'std::vector<std::__cxx11::basic_string<char> >' and '<unresolved overloaded function type>')
   60 |     while(press(prefix+a[index]) < N)
      |                         ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from combo.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::reference = std::__cxx11::basic_string<char>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::const_reference = const std::__cxx11::basic_string<char>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
combo.cpp:62:14: error: no post-increment operator for type
   62 |         index++;
      |              ^~
combo.cpp:64:16: error: no match for 'operator[]' (operand types are 'std::vector<std::__cxx11::basic_string<char> >' and '<unresolved overloaded function type>')
   64 |     prefix += a[index];
      |                ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from combo.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::reference = std::__cxx11::basic_string<char>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::const_reference = const std::__cxx11::basic_string<char>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~