제출 #798764

#제출 시각아이디문제언어결과실행 시간메모리
798764LIFRarest Insects (IOI22_insects)C++17
25 / 100
206 ms416 KiB
#include "insects.h"
#include <vector>
using namespace std;
bool vis[300005];
bool can[300005];
bool check(int now,int N)
{
	for(int i=0;i<=N-1;i++)
	{
		can[i] = true;
		vis[i] = false;
	}
	vector<int> vv;
	for(int i=0;i<=N-1;i++)
	{
		move_inside(i);
		if(press_button() > now)
		{
			move_outside(i);
			vv.push_back(i);
			vis[i] = true;
		}
	}
	for(int i=0;i<=N-1;i++)if(vis[i] == false)move_outside(i);
	
	for(int i=0;i<vv.size();i++)
	{
		move_inside(vv[i]);
		if(press_button() >= 2)move_outside(vv[i]);
	}
	for(int i=0;i<=N-1;i++)
	{
		if(vis[i] == true)continue;
		move_inside(i);
		if(press_button() >= 2)can[i] = false;
		move_outside(i); // we must move_outside all of things, otherwise it will impact other checks.
	}
	for(int i=0;i<=N-1;i++)
	{
		if(can[i] == true && vis[i] == false)return true;
	}
	return false;
}
int min_cardinality(int N) {
	int l = 1;
	int r = N;
	int ans = N;
	while(l <= r)
	{
		int mid = (l+r)>>1;
		if(check(mid,N) == true)
		{
			r = mid-1;
			ans = mid;
		}
		else l = mid+1;
	}
  	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In function 'bool check(int, int)':
insects.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=0;i<vv.size();i++)
      |              ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...