답안 #988516

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988516 2024-05-25T05:09:36 Z cnn008 드문 곤충 (IOI22_insects) C++17
0 / 100
2 ms 600 KB
#include "bits/stdc++.h"
using namespace std;

#include "insects.h"

#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif

#define ll long long

const int N=1e5+5;
const int mod=1e9+7;

int cad;
set <int> s;
int min_cardinality(int n){
	auto add = [&](int i) -> void{
		s.insert(i);
		move_inside(i);
	};
	auto del = [&](int i) -> void{
		s.erase(i);
		move_outside(i);
	};
	auto check = [&](int k) -> bool{
		for(int i=0; i<n; i++){
			add(i);
			if(press_button()>k) del(i);
		}
		return (int)s.size()>=cad*k;
	};
	for(int i=0; i<n; i++){
		add(i);
		if(press_button()==1) cad++;
		else del(i);
	}
	for(auto i:s) del(i);
	int l=2,r=n/cad,ans=1;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}else r=mid-1;
		for(auto i:s) del(i);
	}
}
/**  /\_/\
*   (= ._.)
*   / >💖 \>💕
**/

Compilation message

insects.cpp:51:9: warning: "/*" within comment [-Wcomment]
   51 | /**  /\_/\
      |          
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:41:18: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   41 |  int l=2,r=n/cad,ans=1;
      |                  ^~~
insects.cpp:50:1: warning: no return statement in function returning non-void [-Wreturn-type]
   50 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -