제출 #1335254

#제출 시각아이디문제언어결과실행 시간메모리
1335254gelastropod드문 곤충 (IOI22_insects)C++20
47.50 / 100
59 ms432 KiB
#include "insects.h"

#include <bits/stdc++.h>
using namespace std;

#define qry press_button

bitset<2000> bs, bs1, bs2, bs3;
int numinc = 0;

void add(int n) {
	if (!bs[n]) {
		move_inside(n);
		numinc++;
	}
	bs[n] = 1;
}

void rem(int n) {
	if (bs[n]) {
		move_outside(n);
		numinc--;
	}
	bs[n] = 0;
}

int min_cardinality(int N) {
	int numu = 0;
	for (int i = 0; i < N; i++) {
		add(i);
		if (qry() > 1) rem(i);
		else numu++;
	}
	int low = 2, high = N / numu, ans = 1;
	while (low <= high) {
		int x = (low + high) / 2;
		bs1 = 0;
		for (int i = 0; i < N; i++) {
			if (bs1[i]) continue;
			add(i);
			if (qry() > x) {
				rem(i);
				bs1[i] = 1;
			}
		}
		if (numinc == numu * x) low = x + 1, ans = x;
		else {
			high = x - 1;
			for (int i = 0; i < N; i++) rem(i);
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...