Submission #1314398

#TimeUsernameProblemLanguageResultExecution timeMemory
1314398PlayVoltzRarest Insects (IOI22_insects)C++20
47.50 / 100
63 ms432 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

int min_cardinality(int n){
	int uq=1;
	move_inside(0);
	vector<int> temp;
	for (int i=1; i<n; ++i){
		move_inside(i);
		temp.pb(i);
		if (press_button()==2)move_outside(i), temp.pop_back();
		else ++uq;
	}
	for (auto a:temp)move_outside(a);
	int low=1, high=n/uq+1;
	while (low+1<high){
		int mid=(low+high)/2, c=0;
		vector<int> temp;
		for (int i=0; i<n; ++i){
			move_inside(i);
			temp.pb(i);
			if (press_button()>mid)move_outside(i), temp.pop_back();
			else ++c;
		}
		for (auto a:temp)move_outside(a);
		if (c==uq*mid)low=mid;
		else high=mid;
	}
	return low;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...