답안 #857905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857905 2023-10-07T07:09:18 Z firewater 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include "insects.h"
#include<bits/stdc++.h>
#define MX 2023
using namespace std;
int n,m,l,r,num,sav,p[MX],pp[MX];
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 rd(int l,int r)
{
	return rdd()%(r-l+1)+l;
}
int min_cardinality(int N) {
	n=N;
	for(int i=0;i<n;++i){
		move_inside(i);
		if(press_button()>1)move_outside(i);
		else p[i]=1,num++;
	}
	m=num;
	l=1;
	r=n/m;
	sav=-1;
	while(l<r){
		int mid=l+r+1>>1;
		d.clear();
		if(sav!=-1){
			d.push_back(sav);
			sav=-1;
		}
		if(check(mid)==mid*m)l=mid;
		else{
			r=mid-1;
			for(int i=0;i<n;++i)
				if(!p[i])pp[i]=1;
			for(int i=1;i<d.size();++i){
				p[d[i]]=0;
				move_outside(d[i]);
				num--;
			}
			sav=d[0];
		}
	}
	return l;
}

Compilation message

insects.cpp: In function 'int rd(int, int)':
insects.cpp:23:9: error: 'rdd' was not declared in this scope; did you mean 'rd'?
   23 |  return rdd()%(r-l+1)+l;
      |         ^~~
      |         rd
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:37:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |   int mid=l+r+1>>1;
      |           ~~~^~
insects.cpp:48:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    for(int i=1;i<d.size();++i){
      |                ~^~~~~~~~~