Submission #1078100

# Submission time Handle Problem Language Result Execution time Memory
1078100 2024-08-27T12:43:26 Z Muhammad_Aneeq Rarest Insects (IOI22_insects) C++17
53.01 / 100
602 ms 29444 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&&ind.size()<colors*mid;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:41:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   for (int i=0;i<N&&ind.size()<colors*mid;i++)
      |                     ~~~~~~~~~~^~~~~~~~~~~
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 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 368 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 5 ms 700 KB Output is correct
9 Correct 7 ms 600 KB Output is correct
10 Correct 7 ms 620 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 6 ms 552 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 6 ms 572 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 7 ms 688 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 8 ms 600 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
# 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 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 368 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 5 ms 700 KB Output is correct
9 Correct 7 ms 600 KB Output is correct
10 Correct 7 ms 620 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 6 ms 552 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 6 ms 572 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 7 ms 688 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 8 ms 600 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 5 ms 344 KB Output is correct
24 Correct 21 ms 2776 KB Output is correct
25 Correct 82 ms 5192 KB Output is correct
26 Correct 108 ms 7780 KB Output is correct
27 Correct 73 ms 3036 KB Output is correct
28 Correct 13 ms 1280 KB Output is correct
29 Correct 89 ms 4252 KB Output is correct
30 Correct 69 ms 4368 KB Output is correct
31 Correct 131 ms 5704 KB Output is correct
32 Correct 108 ms 6636 KB Output is correct
33 Correct 139 ms 8376 KB Output is correct
34 Correct 120 ms 6540 KB Output is correct
35 Correct 100 ms 6296 KB Output is correct
36 Correct 95 ms 6608 KB Output is correct
37 Correct 132 ms 6464 KB Output is correct
38 Correct 63 ms 4940 KB Output is correct
39 Correct 60 ms 4020 KB Output is correct
40 Correct 39 ms 3148 KB Output is correct
41 Correct 19 ms 1864 KB Output is correct
# 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 1 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 Partially correct 0 ms 344 KB Output is partially correct
7 Correct 13 ms 696 KB Output is correct
8 Correct 65 ms 8428 KB Output is correct
9 Partially correct 410 ms 21420 KB Output is partially correct
10 Partially correct 468 ms 29412 KB Output is partially correct
11 Partially correct 203 ms 9304 KB Output is partially correct
12 Correct 103 ms 8700 KB Output is correct
13 Partially correct 251 ms 13320 KB Output is partially correct
14 Partially correct 253 ms 14456 KB Output is partially correct
15 Partially correct 418 ms 19040 KB Output is partially correct
16 Partially correct 507 ms 23608 KB Output is partially correct
17 Partially correct 480 ms 21296 KB Output is partially correct
18 Partially correct 445 ms 26400 KB Output is partially correct
19 Partially correct 602 ms 26292 KB Output is partially correct
20 Partially correct 488 ms 29444 KB Output is partially correct
21 Partially correct 353 ms 27736 KB Output is partially correct
22 Partially correct 303 ms 23468 KB Output is partially correct
23 Partially correct 191 ms 14164 KB Output is partially correct
24 Correct 193 ms 15260 KB Output is correct
25 Correct 141 ms 11744 KB Output is correct
26 Correct 59 ms 6316 KB Output is correct
27 Partially correct 341 ms 18236 KB Output is partially correct
28 Partially correct 322 ms 28372 KB Output is partially correct
29 Partially correct 388 ms 20112 KB Output is partially correct
30 Partially correct 396 ms 20956 KB Output is partially correct
31 Partially correct 352 ms 23872 KB Output is partially correct
32 Partially correct 356 ms 27620 KB Output is partially correct
33 Partially correct 216 ms 15188 KB Output is partially correct
34 Partially correct 182 ms 13468 KB Output is partially correct
35 Partially correct 401 ms 19844 KB Output is partially correct
36 Partially correct 342 ms 23632 KB Output is partially correct
37 Partially correct 350 ms 23724 KB Output is partially correct
38 Partially correct 360 ms 23588 KB Output is partially correct
39 Partially correct 324 ms 17740 KB Output is partially correct
40 Partially correct 270 ms 21852 KB Output is partially correct
41 Partially correct 420 ms 24296 KB Output is partially correct
42 Partially correct 427 ms 20684 KB Output is partially correct
43 Partially correct 31 ms 1176 KB Output is partially correct
44 Partially correct 143 ms 6512 KB Output is partially correct
45 Partially correct 342 ms 9292 KB Output is partially correct
46 Correct 72 ms 4916 KB Output is correct
47 Correct 130 ms 10456 KB Output is correct
48 Correct 75 ms 8524 KB Output is correct