Submission #1078187

# Submission time Handle Problem Language Result Execution time Memory
1078187 2024-08-27T13:45:13 Z Faisal_Saqib Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
using namespace std;
void move_inside(int i);
void move_outside(int i);
int press_button();
int min_cardinality(int n)
{
	vector<int> heads={1};
	set<int> machine;
	int one=1,sm=0;
	machine.insert(1);
	for(int i=2;i<=n;i++)
	{
		move_inside(i);
		if(press_button()==1)
		{
			sm++;
			heads.push_back(i);
			machine.insert(i);
		}
		else
			move_outside(i);
	}
	// for(auto i:machine)
	// 	move_outside(i),sm--;
	// machine.clear();
	int sz=heads.size(),np=n;
	while(1)
	{
		int mid=(np)/sz;
		for(auto i:machine)
			move_outside(i),sm--;
		machine.clear();
		for(int i=1;i<=n and sm<(sz*mid);i++)
		{
			if(machine.find(i)==machine.end())
			{
				move_inside(i);
				if(press_button()>mid)
				{
					move_outside(i);
				}
				else
				{
					sm++;
					machine.insert(i);
				}
			}
		}
		if(sm==((sz*mid)))
		{
			return mid; // this is the answer
		}
		else{
			np=sm;
		}
	}
	return -1;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:10:6: warning: unused variable 'one' [-Wunused-variable]
   10 |  int one=1,sm=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer 6 violates the range [0, 5]
2 Halted 0 ms 0 KB -