Submission #835415

# Submission time Handle Problem Language Result Execution time Memory
835415 2023-08-23T14:16:28 Z pavement Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 208 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

int min_cardinality(int N) {
	vector<int> v;
	move_inside(0);
	v.pb(0);
	for (int i = 1, prv = 1; i < N; i++) {
		move_inside(i);
		if (press_button() != prv) {
			move_outside(i);
		} else {
			v.pb(i);
			prv++;
		}
	}
	int lo = 1, hi = N, ans = -1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		vector<int> to_remove;
		for (int i = 0; i < N; i++) {
			if (!binary_search(v.begin(), v.end(), i)) {
				move_inside(i);
				if (press_button() > mid) {
					move_outside(i);
				} else {
					to_remove.pb(i);
				}
			}
		}
		if ((int)to_remove.size() == (int)v.size() * (mid - 1)) {
			ans = mid;
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
		for (auto i : to_remove) {
			move_outside(i);
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 1 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Incorrect 1 ms 208 KB Wrong answer.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 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 Incorrect 0 ms 208 KB Wrong answer.
7 Halted 0 ms 0 KB -