Submission #1061533

# Submission time Handle Problem Language Result Execution time Memory
1061533 2024-08-16T10:37:57 Z jamjanek Rarest Insects (IOI22_insects) C++17
0 / 100
256 ms 688 KB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int k;
void wyczysc(set<int>&sett){
	for(auto j: sett)
		move_outside(j);
	sett.clear();
}
int min_cardinality(int n) {
	set<int>srodek;
	vector<int>pozostale;
	move_inside(0);
	srodek.insert(0);
	k = 1;
	for(int i=1;i<n;i++){
		move_inside(i);
		if(press_button()>1){
			pozostale.push_back(i);
			move_outside(i);
		}
		else{
			k++;
			srodek.insert(i);
		}
	}
	int wys = 1;

	//k*5>=n to mozna od razu zrobic
	if(k*5>=n){
		for(int i=0;i<4;i++){
			int k1 = 0;
			wyczysc(srodek);
			vector<int>jeszcze;
			for(auto j: pozostale)jeszcze.push_back(j);
			pozostale.clear();
			for(auto j: jeszcze){
				move_inside(j);
				if(press_button()>1){
					pozostale.push_back(j);
					move_outside(j);
				}
				else{
					k1++;
					srodek.insert(j);
				}				
			}
			if(k1==k)wys++;
			else
				return wys;
		}
		return wys;
	}

	
	n-=k*wys;
	while(n>=k){
		int k1 = 0;
		int srodekH = (n+2*k-1)/(2*k);
		wyczysc(srodek);

		vector<int>nadmiar;
		vector<int>jeszcze;
		for(auto j: pozostale)jeszcze.push_back(j);
		pozostale.clear();
		
		for(auto j: jeszcze){
			move_inside(j);
			if(press_button()>srodekH){
				nadmiar.push_back(j);
				move_outside(j);
			}
			else{
				srodek.insert(j);
				k1++;
			}
		}
		if(k1==k*srodekH){
			wyczysc(srodek);
			n-=k*srodekH;
			wys+=srodekH;
			pozostale = nadmiar;
		}
		else{
			for(auto j: srodek){
				pozostale.push_back(j);
			}
			wyczysc(srodek);
		}
	}
	return wys;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 432 KB Output is correct
9 Incorrect 256 ms 344 KB Too many queries.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 432 KB Output is correct
9 Incorrect 256 ms 344 KB Too many queries.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 28 ms 600 KB Output is correct
8 Correct 8 ms 600 KB Output is correct
9 Correct 26 ms 688 KB Output is correct
10 Incorrect 253 ms 676 KB Too many queries.
11 Halted 0 ms 0 KB -