답안 #241961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241961 2020-06-26T12:33:39 Z valerikk Xoractive (IZhO19_xoractive) C++17
컴파일 오류
0 ms 0 KB
#include "interactive.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
//#define int ll

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(), (a).end()

vector<int> get_xor(vector<int> pos) {
  for (auto &i : pos) i++;
  auto kek = get_pairwise_xor(pos);
  map<int, int> cnt;
  for (auto i : kek) {
    if (i != 0) cnt[i]++;
  }
  vector<int> flex;
  for (auto i : cnt) {
    i.y /= 2;
    while (i.y--) {
      flex.pb(i.x);
    }
  }
  return flex;
}

vector<int> get_kek(int a1, vector<int> pos) {
  auto kek1 = get_xor(pos);
  pos.pb(0);
  auto kek2 = get_xor(pos);
  map<int, int> cnt;
  for (auto i : kek2) cnt[i]++;
  for (auto i : kek1) cnt[i]--;
  vector<int> res;
  for (auto i : cnt) {
    if (i.y) {
      res.pb(i.x ^ a1);
    }
  }
  return res;
}

vector<int> guess(int n) {
  vector<int> a(n);
  a[0] = ask(1);
  set<int> st;
  vector<set<int>> have(7);
  for (int i = 0; i < 7; i++) {
    vector<int> pos;
    for (int j = 1; j < n; j++) {
      if ((j >> i) & 1) pos.pb(j);
    }
    have[i] = get_kek(a[0], pos);
    for (auto j : have[i]) st.insert(j);
  }
  for (auto i : st) {
    int ind = 0;
    for (int j = 0; j < 7; j++) {
      if (have[j].count(i)) ind += 1 << j;
    }
    a[ind] = i;
  }
  return a;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:59:32: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::set<int> > >::value_type {aka std::set<int>}' and 'std::vector<int>')
     have[i] = get_kek(a[0], pos);
                                ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from Xoractive.cpp:2:
/usr/include/c++/7/bits/stl_set.h:288:7: note: candidate: std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(const std::set<_Key, _Compare, _Alloc>&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       operator=(const set&) = default;
       ^~~~~~~~
/usr/include/c++/7/bits/stl_set.h:288:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::set<int>&'
/usr/include/c++/7/bits/stl_set.h:292:7: note: candidate: std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::set<_Key, _Compare, _Alloc>&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       operator=(set&&) = default;
       ^~~~~~~~
/usr/include/c++/7/bits/stl_set.h:292:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::set<int>&&'
/usr/include/c++/7/bits/stl_set.h:306:7: note: candidate: std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/stl_set.h:306:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<int>'