Submission #834966

# Submission time Handle Problem Language Result Execution time Memory
834966 2023-08-23T03:51:02 Z pavement Rarest Insects (IOI22_insects) C++17
10 / 100
59 ms 408 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

vector<int> cur_v, perm;

int qry(vector<int> v) {
	sort(v.begin(), v.end());
	vector<int> chng;
	set_symmetric_difference(v.begin(), v.end(), cur_v.begin(), cur_v.end(), back_inserter(chng));
	for (int i : chng) {
		if (binary_search(v.begin(), v.end(), i)) {
			move_inside(perm[i]);
		} else {
			move_outside(perm[i]);
		}
	}
	cur_v = v;
	return press_button();
}

mt19937 rng(998244353);

int min_cardinality(int N) {
	perm.resize(N);
	iota(perm.begin(), perm.end(), 0);
	shuffle(perm.begin(), perm.end(), rng);
	vector<int> rep, cnt(N, 0);
	for (int i = 0; i < N; i++) {
		int lnk = -1;
		{
			shuffle(rep.begin(), rep.end(), rng);
			int lo = 0, hi = (int)rep.size() - 1;
			while (lo <= hi) {
				int mid = (lo + hi) / 2;
				vector<int> cur = {i};
				for (int j = 0; j <= mid; j++) {
					cur.pb(rep[j]);
				}
				if (qry(cur) > 1) {
					lnk = rep[mid];
					hi = mid - 1;
				} else {
					lo = mid + 1;
				}
			}
		}
		if (lnk == -1) {
			cnt[i]++;
			rep.pb(i);
		} else {
			cnt[lnk]++;
		}
	}
	int ret = N;
	for (int i = 0; i < N; i++) {
		if (cnt[i]) {
			ret = min(ret, cnt[i]);
		}
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 20 ms 328 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 11 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 7 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 7 ms 208 KB Output is correct
20 Correct 10 ms 208 KB Output is correct
21 Correct 11 ms 208 KB Output is correct
22 Correct 16 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 20 ms 328 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 2 ms 208 KB Output is correct
11 Correct 11 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 7 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 7 ms 208 KB Output is correct
20 Correct 10 ms 208 KB Output is correct
21 Correct 11 ms 208 KB Output is correct
22 Correct 16 ms 316 KB Output is correct
23 Correct 6 ms 208 KB Output is correct
24 Incorrect 59 ms 404 KB Too many queries.
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 11 ms 256 KB Output is correct
8 Incorrect 52 ms 408 KB Too many queries.
9 Halted 0 ms 0 KB -