Submission #1078095

# Submission time Handle Problem Language Result Execution time Memory
1078095 2024-08-27T12:39:59 Z Muhammad_Aneeq Rarest Insects (IOI22_insects) C++17
50 / 100
525 ms 37564 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 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 1 ms 344 KB Output is correct
7 Correct 2 ms 480 KB Output is correct
8 Correct 6 ms 600 KB Output is correct
9 Correct 7 ms 628 KB Output is correct
10 Correct 8 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 7 ms 552 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 7 ms 828 KB Output is correct
15 Correct 6 ms 600 KB Output is correct
16 Correct 6 ms 600 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 6 ms 656 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 4 ms 600 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 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 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 1 ms 344 KB Output is correct
7 Correct 2 ms 480 KB Output is correct
8 Correct 6 ms 600 KB Output is correct
9 Correct 7 ms 628 KB Output is correct
10 Correct 8 ms 600 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 7 ms 552 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 7 ms 828 KB Output is correct
15 Correct 6 ms 600 KB Output is correct
16 Correct 6 ms 600 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 6 ms 656 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 4 ms 600 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 6 ms 600 KB Output is correct
24 Correct 26 ms 2384 KB Output is correct
25 Correct 86 ms 6508 KB Output is correct
26 Correct 122 ms 8336 KB Output is correct
27 Correct 81 ms 3040 KB Output is correct
28 Correct 20 ms 1388 KB Output is correct
29 Correct 76 ms 4220 KB Output is correct
30 Correct 64 ms 4432 KB Output is correct
31 Correct 115 ms 7504 KB Output is correct
32 Correct 112 ms 8168 KB Output is correct
33 Correct 123 ms 9296 KB Output is correct
34 Correct 128 ms 8120 KB Output is correct
35 Correct 135 ms 8016 KB Output is correct
36 Correct 116 ms 8668 KB Output is correct
37 Correct 96 ms 6848 KB Output is correct
38 Correct 75 ms 4380 KB Output is correct
39 Correct 41 ms 3664 KB Output is correct
40 Correct 31 ms 3156 KB Output is correct
41 Correct 23 ms 1920 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 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 Partially correct 1 ms 344 KB Output is partially correct
7 Correct 18 ms 592 KB Output is correct
8 Correct 77 ms 8408 KB Output is correct
9 Partially correct 379 ms 27576 KB Output is partially correct
10 Partially correct 358 ms 29428 KB Output is partially correct
11 Partially correct 218 ms 9688 KB Output is partially correct
12 Correct 91 ms 8632 KB Output is correct
13 Partially correct 236 ms 13668 KB Output is partially correct
14 Partially correct 188 ms 14680 KB Output is partially correct
15 Partially correct 453 ms 26472 KB Output is partially correct
16 Partially correct 478 ms 30708 KB Output is partially correct
17 Partially correct 452 ms 27768 KB Output is partially correct
18 Partially correct 424 ms 31220 KB Output is partially correct
19 Partially correct 517 ms 34472 KB Output is partially correct
20 Partially correct 477 ms 33596 KB Output is partially correct
21 Partially correct 396 ms 29380 KB Output is partially correct
22 Partially correct 344 ms 26692 KB Output is partially correct
23 Partially correct 153 ms 14368 KB Output is partially correct
24 Correct 149 ms 15252 KB Output is correct
25 Correct 157 ms 11728 KB Output is correct
26 Correct 55 ms 6224 KB Output is correct
27 Partially correct 257 ms 18432 KB Output is partially correct
28 Partially correct 361 ms 37564 KB Output is partially correct
29 Partially correct 348 ms 20528 KB Output is partially correct
30 Partially correct 482 ms 21372 KB Output is partially correct
31 Partially correct 390 ms 23996 KB Output is partially correct
32 Partially correct 346 ms 28156 KB Output is partially correct
33 Partially correct 193 ms 15096 KB Output is partially correct
34 Partially correct 164 ms 15164 KB Output is partially correct
35 Partially correct 302 ms 19896 KB Output is partially correct
36 Partially correct 426 ms 28400 KB Output is partially correct
37 Partially correct 335 ms 23836 KB Output is partially correct
38 Partially correct 322 ms 23688 KB Output is partially correct
39 Partially correct 252 ms 17844 KB Output is partially correct
40 Partially correct 266 ms 31128 KB Output is partially correct
41 Partially correct 431 ms 28964 KB Output is partially correct
42 Partially correct 351 ms 20816 KB Output is partially correct
43 Partially correct 25 ms 1104 KB Output is partially correct
44 Partially correct 140 ms 6604 KB Output is partially correct
45 Partially correct 525 ms 19616 KB Output is partially correct
46 Correct 41 ms 4724 KB Output is correct
47 Correct 114 ms 10320 KB Output is correct
48 Correct 79 ms 8524 KB Output is correct