Submission #787282

#TimeUsernameProblemLanguageResultExecution timeMemory
787282ono_de206Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

//#define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
set<int> all;

void add(int i) {
	if(all.count(i)) return;
	move_inside(i);
	all.in(i);
}

void rem(int i) {
	if(!all.count(i)) return;
	move_outside(i);
	all.erase(i);
}

int solve(vector<int> a, vector<int> b) {
	if(a.size() == 1) {
		rem(a[0]);
		return (int)a.size() + (int)b.size();
	}
	if(b.size() < a.size()) {
		for(int x : a) {
			rem(x);
		}
		return 1;
	}
	random_shuffle(all(a), rng);
	vector<int> a1, a2, b1, b2;
	int sz = a.size();
	for(int i = 0; i < sz / 2; i++) {
		a1.pb(a[i]);
		add(a[i]);
	}
	for(int i = sz / 2; i < sz; i++) {
		a2.pb(a[i]);
		rem(a[i]);
	}
	for(int x : b) {
		add(x);
		if(press_button() > 1) b1.pb(x);
		else b2.pb(x);
		rem(x);
	}
	return min(solve(a1, b1), solve(a2, b2));
}

int min_cardinality(int n) {
	vector<int> a, b;
	for(int i = 0; i < n; i++) {
		a.pb(i);
		add(i);
		if(press_button() > 1) {
			a.pop_back();
			b.pb(i);
			rem(i);
		}
	}
	return solve(a, b);
}

Compilation message (stderr)

In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from insects.cpp:2:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Generator = std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>&]':
insects.cpp:47:28:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:51,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from insects.cpp:2:
/usr/include/c++/10/bits/random.tcc:450:5: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 64; long unsigned int __n = 312; long unsigned int __m = 156; long unsigned int __r = 31; _UIntType __a = 13043109905998158313; long unsigned int __u = 29; _UIntType __d = 6148914691236517205; long unsigned int __s = 17; _UIntType __b = 8202884508482404352; long unsigned int __t = 37; _UIntType __c = 18444473444759240704; long unsigned int __l = 43; _UIntType __f = 6364136223846793005; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  450 |     mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  451 |        __s, __b, __t, __c, __l, __f>::
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.tcc:450:5: note:   candidate expects 0 arguments, 1 provided