Submission #785058

# Submission time Handle Problem Language Result Execution time Memory
785058 2023-07-17T03:25:03 Z Hanksburger Xoractive (IZhO19_xoractive) C++17
Compilation error
0 ms 0 KB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> res[7], v, p, q, t;
vector<int> guess(int n)
{
    int x=ask(1);
    for (int i=0; i<=6; i++)
    {
        t.clear();
        for (int j=2; j<=n; j++)
            if (j&(1<<i))
                t.push_back(j);
        if (t.empty())
            p.clear();
        else
            p=get_pairwise_xor(t);
        t.push_back(1);
        q=get_pairwise_xor(t);
        for (int u:p)
            q.erase(find(q.begin(), q.end(), u));
        for (int j=1; j<q.size(); j+=2)
        {
            v.push_back(q[j]^x);
            res[i].push_back(q[j]^x);
        }
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()));
    vector<int> ans(n);
    ans[0]=x;
    for (int u:v)
    {
        int ind=0;
        for (int i=0; i<=6; i++)
            if (find(res[i].begin(), res[i].end(), u)!=res[i].end())
                ind|=1<<i;
        ans[ind-1]=u;
    }
    return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j=1; j<q.size(); j+=2)
      |                       ~^~~~~~~~~
Xoractive.cpp:29:40: error: no matching function for call to 'std::vector<int>::resize(__gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   29 |     v.resize(unique(v.begin(), v.end()));
      |                                        ^
In file included from /usr/include/c++/10/vector:67,
                 from interactive.h:5,
                 from Xoractive.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:937:24: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
  937 |       resize(size_type __new_size)
      |              ~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:957:7: note:   candidate expects 2 arguments, 1 provided