Submission #1078093

# Submission time Handle Problem Language Result Execution time Memory
1078093 2024-08-27T12:38:37 Z Muhammad_Aneeq Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
void move_inside(int i);
void move_outside(int i);
int press_button();
#include <iostream>
#include <vector>
#include <map>
using namespace std;
map<vector<int>,int>d;
vector<int>ind;
int ask()
{
	if (d.find(ind)==d.end())
		return d[ind];
	d[ind]=press_button();
	return d[ind];
}
int min_cardinality(int N)
{
	int colors=0;
	for (int i=0;i<N;i++)
	{
		move_inside(i);
		ind.push_back(i);
		if (ask()==2)
		{
			move_outside(i);
			ind.pop_back();
		}
		else
			colors++;
	}
	if (colors==1)
		return N;
	for (auto i:ind)
		move_outside(i);
	int st=1,en=N/colors+1;
	while (st+1<en)
	{
		int mid=(st+en)/2;
		ind={};
		for (int i=0;i<N;i++)
		{
			move_inside(i);
			ind.push_back(i);
			if (ask()>mid)
			{
				move_outside(i);
				ind.pop_back();
			}
		}
		if (ind.size()==mid*colors)
			st=mid;
		else
			en=mid;
		for (auto i:ind)
			move_outside(i);
	}
	return st;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:51:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |   if (ind.size()==mid*colors)
      |       ~~~~~~~~~~^~~~~~~~~~~~
# 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 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -