Submission #1078089

# Submission time Handle Problem Language Result Execution time Memory
1078089 2024-08-27T12:35:30 Z Faisal_Saqib Rarest Insects (IOI22_insects) C++17
53.53 / 100
944 ms 38020 KB
#include <bits/stdc++.h>
using namespace std;
void move_inside(int i);
void move_outside(int i);
int press_button();
map<vector<int>,int> store;
vector<int> cur,real_;
void add(int i)
{
	i--;
	cur.push_back(i);
}
void rem(int i)
{
	i--;
	cur.pop_back();
}
void khatam()
{
	cur.clear();
}
int ask()
{
	if(store.find(cur)!=store.end())return store[cur];
	for(auto&i:cur)
	{
		if(!binary_search(begin(real_),end(real_),i))
		{
			move_inside(i);
		}
	}
	for(auto&j:real_)
	{
		if(!binary_search(begin(cur),end(cur),j))
		{
			move_outside(j);
		}
	}
	real_=cur;
	store[cur]=press_button();
	// cout<<"asking \n";
	// cout<<"For: ";
	// for(auto i:cur)
	// {
	// 	cout<<i<<' ';
	// }
	// cout<<endl;
	// cout<<"Ans: "<<store[cur]<<endl;
	return store[cur];
}
int min_cardinality(int n)
{
	vector<int> heads={1};
	add(1);
	for(int i=2;i<=n;i++)
	{
		add(i);
		if(ask()==1)
			heads.push_back(i);
		else
			rem(i);
	}
	int sz=heads.size();
	int s=1;
	int e=(n/sz)+1;
	while(s+1<e)
	{
		int mid=(s+e)/2;
		khatam();
		int sm=0;
		for(int i=1;i<=mid;i++)
			add(i),sm++;
		for(int j=mid+1;j<=n;j++)
		{
			add(j);
			if(ask()>mid)
			{
				rem(j);
			}
			else{
				sm++;
			}
		}
		if(sm==((sz*mid)))
		{
			s=mid;
		}
		else{
			e=mid;
		}
	}
	return s;
}
# 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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 7 ms 600 KB Output is correct
9 Correct 11 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 10 ms 832 KB Output is correct
13 Correct 7 ms 600 KB Output is correct
14 Correct 9 ms 600 KB Output is correct
15 Correct 8 ms 756 KB Output is correct
16 Correct 13 ms 600 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 6 ms 460 KB Output is correct
20 Correct 8 ms 600 KB Output is correct
21 Correct 3 ms 456 KB Output is correct
22 Correct 2 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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 7 ms 600 KB Output is correct
9 Correct 11 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 10 ms 832 KB Output is correct
13 Correct 7 ms 600 KB Output is correct
14 Correct 9 ms 600 KB Output is correct
15 Correct 8 ms 756 KB Output is correct
16 Correct 13 ms 600 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 6 ms 460 KB Output is correct
20 Correct 8 ms 600 KB Output is correct
21 Correct 3 ms 456 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 67 ms 3148 KB Output is correct
24 Correct 39 ms 2876 KB Output is correct
25 Correct 152 ms 6340 KB Output is correct
26 Correct 174 ms 8016 KB Output is correct
27 Correct 81 ms 2952 KB Output is correct
28 Correct 18 ms 1488 KB Output is correct
29 Correct 106 ms 4020 KB Output is correct
30 Correct 84 ms 4328 KB Output is correct
31 Correct 158 ms 7428 KB Output is correct
32 Correct 173 ms 7900 KB Output is correct
33 Correct 198 ms 9048 KB Output is correct
34 Correct 199 ms 8272 KB Output is correct
35 Correct 160 ms 7920 KB Output is correct
36 Correct 164 ms 8404 KB Output is correct
37 Correct 117 ms 6896 KB Output is correct
38 Correct 75 ms 4684 KB Output is correct
39 Correct 62 ms 3864 KB Output is correct
40 Correct 61 ms 3452 KB Output is correct
41 Correct 27 ms 1996 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 1 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 231 ms 11420 KB Output is correct
8 Correct 179 ms 10052 KB Output is correct
9 Partially correct 714 ms 26820 KB Output is partially correct
10 Partially correct 700 ms 29512 KB Output is partially correct
11 Partially correct 231 ms 8800 KB Output is partially correct
12 Correct 161 ms 8468 KB Output is correct
13 Partially correct 311 ms 13348 KB Output is partially correct
14 Partially correct 268 ms 14388 KB Output is partially correct
15 Partially correct 805 ms 27056 KB Output is partially correct
16 Partially correct 939 ms 30760 KB Output is partially correct
17 Partially correct 848 ms 28420 KB Output is partially correct
18 Partially correct 870 ms 31668 KB Output is partially correct
19 Partially correct 944 ms 34428 KB Output is partially correct
20 Partially correct 867 ms 33620 KB Output is partially correct
21 Partially correct 628 ms 29688 KB Output is partially correct
22 Partially correct 499 ms 26840 KB Output is partially correct
23 Partially correct 238 ms 14564 KB Output is partially correct
24 Correct 301 ms 15488 KB Output is correct
25 Correct 239 ms 12368 KB Output is correct
26 Correct 144 ms 7204 KB Output is correct
27 Correct 475 ms 19768 KB Output is correct
28 Partially correct 718 ms 38020 KB Output is partially correct
29 Partially correct 570 ms 21656 KB Output is partially correct
30 Partially correct 673 ms 22332 KB Output is partially correct
31 Partially correct 526 ms 24064 KB Output is partially correct
32 Partially correct 663 ms 27876 KB Output is partially correct
33 Partially correct 332 ms 15316 KB Output is partially correct
34 Partially correct 273 ms 15480 KB Output is partially correct
35 Partially correct 557 ms 21148 KB Output is partially correct
36 Partially correct 742 ms 28960 KB Output is partially correct
37 Partially correct 508 ms 24068 KB Output is partially correct
38 Partially correct 549 ms 23892 KB Output is partially correct
39 Correct 426 ms 19648 KB Output is correct
40 Partially correct 647 ms 31660 KB Output is partially correct
41 Partially correct 812 ms 29116 KB Output is partially correct
42 Partially correct 599 ms 22316 KB Output is partially correct
43 Partially correct 32 ms 1104 KB Output is partially correct
44 Partially correct 172 ms 6772 KB Output is partially correct
45 Partially correct 614 ms 20464 KB Output is partially correct
46 Correct 79 ms 4548 KB Output is correct
47 Correct 203 ms 10884 KB Output is correct
48 Correct 133 ms 8512 KB Output is correct