Submission #370675

# Submission time Handle Problem Language Result Execution time Memory
370675 2021-02-24T13:19:36 Z fhvirus Xoractive (IZhO19_xoractive) C++17
Compilation error
0 ms 0 KB
// Knapsack DP is harder than FFT.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb emplace_back
#define FOR(i,n) for(int i = 0; i < (n); ++i)
#define FOO(i,a,b) for(int i = (a); i <= (b); ++i)
#define AI(x) (x).begin(),(x).end()
template<typename I> bool chmax(I &a, I b){ return a < b ? (a = b, true) : false;}
template<typename I> bool chmin(I &a, I b){ return a > b ? (a = b, true) : false;}
#ifdef OWO
#define debug(args...) LKJ("[ " + string(#args) + " ]", args)
void LKJ(){ cerr << endl;}
template<typename I, typename...T> void LKJ(I&&x, T&&...t){ cerr<<x<<", ", LKJ(t...);}
template<typename I> void DE(I a, I b){ while(a < b) cerr<<*a<<" \n"[next(a)==b], ++a;}
#else
#define debug(...) 0
#define DE(...) 0
#endif
#include "interactive.h"
using namespace std;
vector<int> guess(int n) {
	int k = __lg(n) + 1;
	vector<int> ans;
	vector<vector<int>> ss(k, vector<int>());
	ans.pb(ask(1));
	FOR(j,k){
		vector<int> q;
		FOR(i,n) if(i>>j&1) q.pb(i+1);
		vector<int> r = get_pairwise_xor(q);
		
		q.pb(1);
		ss[j] = get_pairwise_xor(q);
		ss[j].erase(ss[j].begin()); // a[0] ^ a[0]
		for(int x: r) ss[j].erase(AI(ss[j]), x);
		for(int &i: ss[j]) i ^= ans[0];
	}
	FOO(i,1,n-1){
		vector<int> v;
		FOR(j,k){
			if((i>>j&1)^1) continue;
			if(v.empty()) v = ss[j];
			else{
				vector<int> w;
				for(int x: ss[j])
					if(v.find(AI(v), x) != v.end())
						w.pb(x);
				v.swap(w);
			}
		}
		FOR(j,k){
			if(i>>j&1) continue;
			for(int x: ss[j]){
				auto it = v.find(AI(v), x);
				if(it != v.end()) v.erase(it);
			}
		}
		ans.pb(v[0]);
	}
	return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:38:41: error: no matching function for call to 'std::vector<int>::erase(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   38 |   for(int x: r) ss[j].erase(AI(ss[j]), x);
      |                                         ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from Xoractive.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1427:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]'
 1427 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/9/bits/stl_vector.h:1427:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/9/bits/stl_vector.h:1454:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]'
 1454 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/9/bits/stl_vector.h:1454:7: note:   candidate expects 2 arguments, 3 provided
Xoractive.cpp:49:11: error: 'class std::vector<int>' has no member named 'find'
   49 |      if(v.find(AI(v), x) != v.end())
      |           ^~~~
Xoractive.cpp:57:17: error: 'class std::vector<int>' has no member named 'find'
   57 |     auto it = v.find(AI(v), x);
      |                 ^~~~