Submission #1042673

# Submission time Handle Problem Language Result Execution time Memory
1042673 2024-08-03T09:29:46 Z Nurislam Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <class F, class _S>
bool chmin(F &u, const _S &v){
	bool flag = false;
	if ( u > v ){
		u = v; flag |= true;
	}
	return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
	bool flag = false;
	if ( u < v ){
		u = v; flag |= true;
	}
	return flag;
}
int min_cardinality(int n) {
	vector<int> v;
	for(int i =0 ; i < n; i++){
		move_inside(i);
		if(press_button() == 1){
			v.pb(i);
		}else move_outside(i);
	}
	int k = v.size();
	int l = 1, r = 1e9+1, ans = 1;
	
	while(l <= r){
		int m = (l+r)>>1;
		vector<int> up, dn;
		for(int i:v){
			move_inside(i);
			if(press_button() <= m){
				dn.pb(i);
			}else{
				up.pb(i);
				move_outside(i);
			}
		}
		if(k*m == (int)dn.size()){
			ans = m;
			l = m+1;
			v = up;
		}else{
			r = m-1;
			v = dn;
		}
		for(auto i:dn)move_outside(i);
		
	}
	return ans;
}

















# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -