Submission #172485

# Submission time Handle Problem Language Result Execution time Memory
172485 2020-01-01T17:51:52 Z emil_physmath Xoractive (IZhO19_xoractive) C++17
Compilation error
0 ms 0 KB
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
using namespace std;
typedef long long llong;

int ans[101];
map<int, bool> isInQ;

inline vector<int> Range(int l, int r)
{
    vector<int> a;
    for (int i = l; i <= r; ++i)
        a.push_back(i);
    return a;
}
inline int LeftHalf(pair<int, int> range)
{
    return Range(range.first, (range.first + range.second) / 2);
}
vector<int> Get(vector<int> ind)
{
    isInQ.clear();
    auto it = find(ind.begin(), ind.end(), 1);
    if (it != ind.end())
        ind.erase(it);
    vector<int> a = get_pairwise_xor(ind);
    ind.push_back(1);
    vector<int> b = get_pairwise_xor(ind);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> res;
    for (int i = (int)b.size() - 1; i >= 0; --i)
        if (!a.empty() && b[i] == a.back())
            a.pop_back();
        else
            isInQ[b[i] ^ ans[1]] = true;
}
vector<int> guess(int n)
{
    ans[0] = ask(1);
    vector<int> a = Get(Range(2, n));
    for (int i = 0; i < a.size(); ++i)
        ans[i + 2] = a[i];
    vector<pair<int, int>> lr;
    lr.push_back({2, n});
    while (lr.size())
    {
        vector<int> q;
        for (int i = 0; i < lr.size(); ++i)
        {
            auto temp = LeftHalf(lr[i]);
            ind.insert(ind.end(), temp.begin(), temp.end());
        }
        Get(ind);
        vector<pair<int, int>> newLr;
        for (int i = 0; i < lr.size(); ++i)
        {
            sort(ans + lr[i].first, ans + lr[i].second + 1, [](int a, int b) {
                 return isInQ[a] > isInQ[b];
            });
            if (lr[i].first != lr[i].second)
            {
                int m = (lr[i].first + lr[i].second) / 2;
                newLr.push_back({lr[i].first, m});
                newLr.push_back({m + 1, lr[i].second});
            }
        }
        lr.swap(newLr);
    }
    return vector<int>(a + 1, a + n + 1);
}

Compilation message

Xoractive.cpp: In function 'int LeftHalf(std::pair<int, int>)':
Xoractive.cpp:20:63: error: cannot convert 'std::vector<int>' to 'int' in return
     return Range(range.first, (range.first + range.second) / 2);
                                                               ^
Xoractive.cpp: In function 'std::vector<int> Get(std::vector<int>)':
Xoractive.cpp:28:21: error: 'get_pairwise_xor' was not declared in this scope
     vector<int> a = get_pairwise_xor(ind);
                     ^~~~~~~~~~~~~~~~
Xoractive.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:42:14: error: 'ask' was not declared in this scope
     ans[0] = ask(1);
              ^~~
Xoractive.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
Xoractive.cpp:51:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < lr.size(); ++i)
                         ~~^~~~~~~~~~~
Xoractive.cpp:54:13: error: 'ind' was not declared in this scope
             ind.insert(ind.end(), temp.begin(), temp.end());
             ^~~
Xoractive.cpp:54:13: note: suggested alternative: 'int'
             ind.insert(ind.end(), temp.begin(), temp.end());
             ^~~
             int
Xoractive.cpp:54:40: error: request for member 'begin' in 'temp', which is of non-class type 'int'
             ind.insert(ind.end(), temp.begin(), temp.end());
                                        ^~~~~
Xoractive.cpp:54:54: error: request for member 'end' in 'temp', which is of non-class type 'int'
             ind.insert(ind.end(), temp.begin(), temp.end());
                                                      ^~~
Xoractive.cpp:56:13: error: 'ind' was not declared in this scope
         Get(ind);
             ^~~
Xoractive.cpp:56:13: note: suggested alternative: 'int'
         Get(ind);
             ^~~
             int
Xoractive.cpp:58:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < lr.size(); ++i)
                         ~~^~~~~~~~~~~
Xoractive.cpp:72:26: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'int')
     return vector<int>(a + 1, a + n + 1);
                        ~~^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/algorithm:61,
                 from Xoractive.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:397:5: note: candidate: template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:397:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/algorithm:61,
                 from Xoractive.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:1198:5: note: candidate: template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)
     operator+(typename move_iterator<_Iterator>::difference_type __n,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:1198:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/vector:65:0,
                 from Xoractive.cpp:2:
/usr/include/c++/7/bits/stl_bvector.h:297:3: note: candidate: std::_Bit_iterator std::operator+(std::ptrdiff_t, const std::_Bit_iterator&)
   operator+(ptrdiff_t __n, const _Bit_iterator& __x)
   ^~~~~~~~
/usr/include/c++/7/bits/stl_bvector.h:297:3: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::ptrdiff_t {aka long int}'
/usr/include/c++/7/bits/stl_bvector.h:387:3: note: candidate: std::_Bit_const_iterator std::operator+(std::ptrdiff_t, const std::_Bit_const_iterator&)
   operator+(ptrdiff_t __n, const _Bit_const_iterator& __x)
   ^~~~~~~~
/usr/include/c++/7/bits/stl_bvector.h:387:3: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::ptrdiff_t {aka long int}'
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5876:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5876:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:53:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.tcc:1157:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const _CharT* __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.tcc:1157:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const _CharT*' and 'std::vector<int>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:53:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.tcc:1173:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.tcc:1173:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5913:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5913:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5929:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5929:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5941:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5941:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5947:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5947:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5953:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5953:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5965:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const _CharT* __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5965:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const _CharT*' and 'std::vector<int>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5971:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(_CharT __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5971:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5977:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5977:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/optional:38,
                 from /usr/include/c++/7/bits/node_handle.h:39,
                 from /usr/include/c++/7/bits/stl_tree.h:72,
                 from /usr/include/c++/7/map:60,
                 from Xoractive.cpp:3:
/usr/include/c++/7/bits/basic_string.h:5983:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/basic_string.h:5983:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
     return vector<int>(a + 1, a + n + 1);
                            ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/algorithm:61,
                 from Xoractive.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:969:5: note: candidate: template<class _Iterator, class _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::operator+(typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:969:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:28: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'int'
     return vector<int>(a + 1, a + n + 1);
                            ^
Xoractive.cpp:72:33: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'int')
     return vector<int>(a + 1, a + n + 1);
                               ~~^~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/algorithm:61,
                 from Xoractive.cpp:1:
/usr/include/c++/7/bits/stl_iterator.h:397:5: note: candidate: template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_iterator.h:397:5: note:   template argument deduction/substitution failed:
Xoractive.cpp:72:35: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
     return vector<int>(a + 1, a + n +