Submission #627648

# Submission time Handle Problem Language Result Execution time Memory
627648 2022-08-12T18:00:04 Z sofapuden Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 208 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

int min_cardinality(int n) {
	int am = 1;
	move_inside(0);
	vector<int> st(n,0);
	st[0] = 1;
	int sz = 1;
	for(int i = 1; i < n; ++i){
		move_inside(i);
		if(press_button() != 1){if(i != n-1)move_outside(i);}
		else am++, st[i] = 1, sz++;
	}
	int l = 2, r = n/am, cur = 1;
	srand(time(0));
	bool fi = 1;
	while(l <= r){
		int m = (l+r)>>1;
		vector<int> rem;
		for(int i = n-1; ~i; ++i){
			if(st[i])continue;
			sz++;
			if(!fi || i != n-1)move_inside(i);
			if(press_button() > m){
				rem.push_back(i);
				sz--;
				move_outside(i);
			}
		}
		if(sz == am*m){
			for(int i = 0; i < n; ++i)st[i] = 1;
			for(auto x : rem)st[x] = 0;
			cur = m;
			l = m + 1;
		}
		else{
			r = m - 1;
			if(l <= r){
				for(auto x : rem)st[x] = 1;
				for(int i = 0; i < n; ++i){
					if(!st[i]){move_outside(i);sz--;}
				}
			}
		}
		fi = 0;
	}
	return cur;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Integer 7 violates the range [0, 5]
2 Halted 0 ms 0 KB -