Submission #1078143

# Submission time Handle Problem Language Result Execution time Memory
1078143 2024-08-27T13:17:59 Z Faisal_Saqib Rarest Insects (IOI22_insects) C++17
25 / 100
1924 ms 80940 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(),np=n;
	while(1)
	{
		int mid=(np)/sz;
		// cout<<"Checking "<<np<<' '<<sz<<endl;
		// cout<<mid<<endl;
		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))
				{
					break;
				}
			}
		}
		// cout<<"Result "<<sm<<endl;
		if(sm==((sz*mid)))
		{
			return mid; // this is the answer
		}
		else{
			np=sm;
		}
	}
	return -1;
}
# 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 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 9 ms 600 KB Output is correct
10 Correct 9 ms 664 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 19 ms 1104 KB Output is correct
13 Correct 16 ms 936 KB Output is correct
14 Correct 7 ms 856 KB Output is correct
15 Correct 5 ms 420 KB Output is correct
16 Correct 7 ms 748 KB Output is correct
17 Correct 9 ms 856 KB Output is correct
18 Correct 14 ms 856 KB Output is correct
19 Correct 12 ms 856 KB Output is correct
20 Correct 7 ms 676 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 2 ms 468 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 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
9 Correct 9 ms 600 KB Output is correct
10 Correct 9 ms 664 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 19 ms 1104 KB Output is correct
13 Correct 16 ms 936 KB Output is correct
14 Correct 7 ms 856 KB Output is correct
15 Correct 5 ms 420 KB Output is correct
16 Correct 7 ms 748 KB Output is correct
17 Correct 9 ms 856 KB Output is correct
18 Correct 14 ms 856 KB Output is correct
19 Correct 12 ms 856 KB Output is correct
20 Correct 7 ms 676 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 5 ms 344 KB Output is correct
24 Correct 40 ms 2896 KB Output is correct
25 Correct 51 ms 3032 KB Output is correct
26 Correct 278 ms 15316 KB Output is correct
27 Correct 89 ms 4416 KB Output is correct
28 Correct 28 ms 1472 KB Output is correct
29 Correct 288 ms 12076 KB Output is correct
30 Correct 618 ms 32388 KB Output is correct
31 Correct 125 ms 5452 KB Output is correct
32 Correct 194 ms 8768 KB Output is correct
33 Correct 276 ms 14468 KB Output is correct
34 Correct 179 ms 8620 KB Output is correct
35 Correct 138 ms 7656 KB Output is correct
36 Correct 256 ms 12348 KB Output is correct
37 Correct 177 ms 11488 KB Output is correct
38 Correct 189 ms 11476 KB Output is correct
39 Correct 116 ms 7344 KB Output is correct
40 Correct 57 ms 3408 KB Output is correct
41 Correct 29 ms 1880 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 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 10 ms 952 KB Output is correct
8 Correct 224 ms 10064 KB Output is correct
9 Correct 192 ms 10888 KB Output is correct
10 Partially correct 1924 ms 80940 KB Output is partially correct
11 Partially correct 302 ms 12832 KB Output is partially correct
12 Correct 153 ms 8460 KB Output is correct
13 Incorrect 976 ms 44340 KB Too many queries.
14 Halted 0 ms 0 KB -