답안 #1078144

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078144 2024-08-27T13:19:50 Z Faisal_Saqib 드문 곤충 (IOI22_insects) C++17
25 / 100
881 ms 81044 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);
	move_inside(i);
}
void rem(int i)
{
	i--;
	cur.pop_back();
	move_outside(i);
}
void khatam()
{
	for(auto i:cur)
		move_outside(i);
	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;
}
# 결과 실행 시간 메모리 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 2 ms 456 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 532 KB Output is correct
9 Correct 8 ms 836 KB Output is correct
10 Correct 9 ms 704 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 16 ms 908 KB Output is correct
13 Correct 16 ms 896 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Correct 4 ms 600 KB Output is correct
16 Correct 7 ms 1112 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 12 ms 856 KB Output is correct
19 Correct 7 ms 912 KB Output is correct
20 Correct 5 ms 680 KB Output is correct
21 Correct 4 ms 528 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 2 ms 456 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 532 KB Output is correct
9 Correct 8 ms 836 KB Output is correct
10 Correct 9 ms 704 KB Output is correct
11 Correct 2 ms 344 KB Output is correct
12 Correct 16 ms 908 KB Output is correct
13 Correct 16 ms 896 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Correct 4 ms 600 KB Output is correct
16 Correct 7 ms 1112 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 12 ms 856 KB Output is correct
19 Correct 7 ms 912 KB Output is correct
20 Correct 5 ms 680 KB Output is correct
21 Correct 4 ms 528 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 5 ms 476 KB Output is correct
24 Correct 26 ms 2256 KB Output is correct
25 Correct 25 ms 3032 KB Output is correct
26 Correct 181 ms 15284 KB Output is correct
27 Correct 78 ms 3764 KB Output is correct
28 Correct 16 ms 1360 KB Output is correct
29 Correct 230 ms 12144 KB Output is correct
30 Correct 456 ms 32248 KB Output is correct
31 Correct 72 ms 5288 KB Output is correct
32 Correct 133 ms 8712 KB Output is correct
33 Correct 207 ms 14720 KB Output is correct
34 Correct 122 ms 8468 KB Output is correct
35 Correct 98 ms 7424 KB Output is correct
36 Correct 161 ms 12344 KB Output is correct
37 Correct 120 ms 11424 KB Output is correct
38 Correct 124 ms 11088 KB Output is correct
39 Correct 100 ms 7536 KB Output is correct
40 Correct 35 ms 3152 KB Output is correct
41 Correct 27 ms 2012 KB Output is correct
# 결과 실행 시간 메모리 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 Partially correct 1 ms 344 KB Output is partially correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 17 ms 568 KB Output is correct
8 Correct 125 ms 8328 KB Output is correct
9 Correct 74 ms 8860 KB Output is correct
10 Partially correct 881 ms 81044 KB Output is partially correct
11 Partially correct 228 ms 13036 KB Output is partially correct
12 Correct 103 ms 8552 KB Output is correct
13 Incorrect 650 ms 44260 KB Too many queries.
14 Halted 0 ms 0 KB -