답안 #1078174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078174 2024-08-27T13:30:40 Z Muhammad_Aneeq 드문 곤충 (IOI22_insects) C++17
25 / 100
2000 ms 153824 KB
void move_inside(int i);
void move_outside(int i);
int press_button();
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
set<int>ind;
map<set<int>,int>d;
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.insert(i);
		if (ask()==2)
		{
			move_outside(i);
			ind.erase(i);
		}
		else
			colors++;
	}
	set<int>ni;
	for (int i=0;i<N;i++)
		if (ind.find(i)==ind.end())
			ni.insert(i);
	if (colors==1)
		return N;
	int st=1,en=N/colors+1;
	while (st+1<en)
	{
		int mid=(st+en)/2;
		for (auto i:ni)
		{
			if (ind.size()==colors*mid)
				break;
			move_inside(i);
			ind.insert(i);
			if (ask()>mid)
			{
				move_outside(i);
				ind.erase(i);
			}
		}
		if (ind.size()==mid*colors)
		{
			for (auto i:ind)
				ni.erase(i);
			st=mid;
		}
		else
		{
			en=mid;
			ni.clear();
			for (auto i:ind)
			{
				ni.insert(i);
				move_outside(i);
			}
			ind.clear();
		}
	}
	return st;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |    if (ind.size()==colors*mid)
      |        ~~~~~~~~~~^~~~~~~~~~~~
insects.cpp:55:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |   if (ind.size()==mid*colors)
      |       ~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 6 ms 1368 KB Output is correct
8 Correct 13 ms 1836 KB Output is correct
9 Correct 12 ms 1568 KB Output is correct
10 Correct 8 ms 856 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 10 ms 1112 KB Output is correct
13 Correct 13 ms 1400 KB Output is correct
14 Correct 16 ms 2388 KB Output is correct
15 Correct 20 ms 2392 KB Output is correct
16 Correct 15 ms 2392 KB Output is correct
17 Correct 15 ms 2392 KB Output is correct
18 Correct 10 ms 1368 KB Output is correct
19 Correct 12 ms 1880 KB Output is correct
20 Correct 16 ms 1880 KB Output is correct
21 Correct 8 ms 1624 KB Output is correct
22 Correct 5 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 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 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 6 ms 1368 KB Output is correct
8 Correct 13 ms 1836 KB Output is correct
9 Correct 12 ms 1568 KB Output is correct
10 Correct 8 ms 856 KB Output is correct
11 Correct 4 ms 856 KB Output is correct
12 Correct 10 ms 1112 KB Output is correct
13 Correct 13 ms 1400 KB Output is correct
14 Correct 16 ms 2388 KB Output is correct
15 Correct 20 ms 2392 KB Output is correct
16 Correct 15 ms 2392 KB Output is correct
17 Correct 15 ms 2392 KB Output is correct
18 Correct 10 ms 1368 KB Output is correct
19 Correct 12 ms 1880 KB Output is correct
20 Correct 16 ms 1880 KB Output is correct
21 Correct 8 ms 1624 KB Output is correct
22 Correct 5 ms 1112 KB Output is correct
23 Correct 7 ms 600 KB Output is correct
24 Correct 243 ms 23932 KB Output is correct
25 Correct 386 ms 36552 KB Output is correct
26 Correct 593 ms 56656 KB Output is correct
27 Correct 131 ms 12292 KB Output is correct
28 Correct 105 ms 12108 KB Output is correct
29 Correct 201 ms 20340 KB Output is correct
30 Correct 244 ms 26336 KB Output is correct
31 Correct 573 ms 44820 KB Output is correct
32 Correct 846 ms 59984 KB Output is correct
33 Correct 715 ms 58288 KB Output is correct
34 Correct 568 ms 47104 KB Output is correct
35 Correct 504 ms 47280 KB Output is correct
36 Correct 440 ms 41624 KB Output is correct
37 Correct 487 ms 47272 KB Output is correct
38 Correct 261 ms 28648 KB Output is correct
39 Correct 271 ms 30800 KB Output is correct
40 Correct 280 ms 29772 KB Output is correct
41 Correct 168 ms 17488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 344 KB Output is correct
7 Correct 11 ms 856 KB Output is correct
8 Correct 1641 ms 94576 KB Output is correct
9 Execution timed out 2561 ms 153824 KB Time limit exceeded
10 Halted 0 ms 0 KB -