답안 #857880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857880 2023-10-07T06:30:46 Z firewater 드문 곤충 (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include "insects.h"
#include<bits/stdc++.h>
#define N 2023
using namespace std;
int n,l,r,num,p[N],pp[N];
vector<int>d;
int check(int x)
{
	for(int i=0;i<n;++i){
		if(p[i]||pp[i])continue;
		move_inside(i);
		if(press_button()>x)move_outside(i);
		else{
			p[i]=1;
			d.push_back(i);
			num++;
		}
	}
	return num;
}
int min_cardinality(int NN) {
	n=NN;
	for(int i=0;i<n;++i)
		move_inside(i);
	r=press_button();
	for(int i=0;i<n;++i)
		move_outside(i);
	l=0;
	num=0;
	while(l<r){
		int mid=l+r+1>>1;
		d.clear();
		if(check(mid)>=mid*n)l=mid;
		else{
			r=mid-1;
			for(int i=0;i<n;++i)
				if(!p[i])pp[i]=1;
			for(int i=0;i<d.size();++i)
				p[d[i]]=0;
		}
	}
	return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |   int mid=l+r+1>>1;
      |           ~~~^~
insects.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for(int i=0;i<d.size();++i)
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -