답안 #799773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799773 2023-08-01T01:33:44 Z LIF 드문 곤충 (IOI22_insects) C++17
93.48 / 100
64 ms 428 KB
#include "insects.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
bool vis[300005];
bool can[300005];
int k = 0;
vector<int> vv2;
bool rub[300005];
vector<int> vv1;
int nown;
bool ys[300005];
int cc[300005];
bool check(int now,int N,int minn)
{
	//if(now == 1)return true;
	vector<int> vv;
	for(int i=0;i<=N-1;i++)vis[i] = false;
	for(int i=0;i<=N-1;i++)
	{
		if(rub[i] == false && ys[i] == false)
		{
			move_inside(i);
			ys[i] = true;
			if(press_button() > now+1)
			{
				move_outside(i);
				vv.push_back(i);
				vis[i] = true;
				ys[i] = false;
			}
			else vv2.push_back(i);
		}
		
	}
/*	cout<<"now: "<<now<<endl;
	cout<<"nown: "<<nown<<endl;
	cout<<"nown-vv.size(): "<<N-vv.size()<<" "<<(now+1) * k<<endl;
	cout<<"vv[i] ";
	for(int i=0;i<vv.size();i++)cout<<vv[i]<<" ";
	cout<<endl;*/
	if(nown-vv.size() < (now+1) * k)
	{
		for(int i=0;i<vv.size();i++)rub[vv[i]] = true;
		for(int i=0;i<=N-1;i++)
		{
			if(vis[i] == false && rub[i] == false && ys[i] == true)
			{
				move_outside(i);
				ys[i] = false;
				if(press_button() <= minn)break;
			}
		}
		nown -= vv.size();
		return true;
	}
	else
	{
		return false;
	}
}
bool first[40005];
int min_cardinality(int N) {
	nown = N;
	int l = 1;
	vector<int> cnt;
	for(int i=0;i<=N-1;i++)
	{
		move_inside(i);
		if(press_button() >= 2)
		{
			move_outside(i);
			first[i] = true;
		}
		else cnt.push_back(i);
	}
	
	for(int i=0;i<=N-1;i++)
	{
		if(first[i] == false)move_outside(i);
	}
	k = cnt.size();
	//if(k == 1)return N;
	int r = (N)/k;
	int ans = (N)/k;
	while(l <= r)
	{
		int mid = (l+r)>>1;
		if(check(mid,N,l) == true)
		{
			r = mid-1;
			ans = mid;
		}
		else l = mid+1;
	}
  	return ans;
}

Compilation message

insects.cpp: In function 'bool check(int, int, int)':
insects.cpp:42:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |  if(nown-vv.size() < (now+1) * k)
      |     ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
insects.cpp:44:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=0;i<vv.size();i++)rub[vv[i]] = true;
      |               ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 4 ms 324 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 208 KB Output is correct
15 Correct 5 ms 324 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 6 ms 324 KB Output is correct
19 Correct 5 ms 324 KB Output is correct
20 Correct 6 ms 320 KB Output is correct
21 Correct 4 ms 320 KB Output is correct
22 Correct 4 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 5 ms 332 KB Output is correct
9 Correct 6 ms 324 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 4 ms 324 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 208 KB Output is correct
15 Correct 5 ms 324 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 6 ms 324 KB Output is correct
19 Correct 5 ms 324 KB Output is correct
20 Correct 6 ms 320 KB Output is correct
21 Correct 4 ms 320 KB Output is correct
22 Correct 4 ms 324 KB Output is correct
23 Correct 20 ms 312 KB Output is correct
24 Correct 13 ms 336 KB Output is correct
25 Correct 24 ms 320 KB Output is correct
26 Correct 25 ms 312 KB Output is correct
27 Correct 26 ms 308 KB Output is correct
28 Correct 18 ms 316 KB Output is correct
29 Correct 22 ms 336 KB Output is correct
30 Correct 14 ms 320 KB Output is correct
31 Correct 24 ms 324 KB Output is correct
32 Correct 27 ms 320 KB Output is correct
33 Correct 19 ms 336 KB Output is correct
34 Correct 27 ms 316 KB Output is correct
35 Correct 28 ms 316 KB Output is correct
36 Correct 20 ms 316 KB Output is correct
37 Correct 28 ms 324 KB Output is correct
38 Correct 30 ms 320 KB Output is correct
39 Correct 23 ms 312 KB Output is correct
40 Correct 20 ms 312 KB Output is correct
41 Correct 24 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 47 ms 312 KB Output is correct
8 Correct 32 ms 328 KB Output is correct
9 Correct 35 ms 300 KB Output is correct
10 Partially correct 46 ms 328 KB Output is partially correct
11 Correct 39 ms 316 KB Output is correct
12 Correct 32 ms 312 KB Output is correct
13 Partially correct 32 ms 340 KB Output is partially correct
14 Partially correct 51 ms 308 KB Output is partially correct
15 Partially correct 49 ms 316 KB Output is partially correct
16 Partially correct 36 ms 428 KB Output is partially correct
17 Partially correct 44 ms 208 KB Output is partially correct
18 Partially correct 46 ms 316 KB Output is partially correct
19 Partially correct 56 ms 296 KB Output is partially correct
20 Partially correct 47 ms 308 KB Output is partially correct
21 Partially correct 60 ms 328 KB Output is partially correct
22 Partially correct 64 ms 312 KB Output is partially correct
23 Partially correct 50 ms 332 KB Output is partially correct
24 Partially correct 50 ms 328 KB Output is partially correct
25 Correct 44 ms 320 KB Output is correct
26 Correct 36 ms 328 KB Output is correct
27 Correct 37 ms 312 KB Output is correct
28 Correct 43 ms 312 KB Output is correct
29 Correct 40 ms 308 KB Output is correct
30 Correct 49 ms 316 KB Output is correct
31 Partially correct 56 ms 328 KB Output is partially correct
32 Partially correct 49 ms 312 KB Output is partially correct
33 Partially correct 53 ms 328 KB Output is partially correct
34 Partially correct 48 ms 308 KB Output is partially correct
35 Correct 21 ms 320 KB Output is correct
36 Partially correct 47 ms 208 KB Output is partially correct
37 Partially correct 59 ms 296 KB Output is partially correct
38 Partially correct 56 ms 316 KB Output is partially correct
39 Correct 50 ms 328 KB Output is correct
40 Correct 37 ms 312 KB Output is correct
41 Partially correct 37 ms 320 KB Output is partially correct
42 Correct 40 ms 428 KB Output is correct
43 Partially correct 9 ms 208 KB Output is partially correct
44 Correct 27 ms 316 KB Output is correct
45 Correct 47 ms 304 KB Output is correct
46 Correct 33 ms 320 KB Output is correct
47 Correct 27 ms 320 KB Output is correct
48 Correct 27 ms 312 KB Output is correct