답안 #826840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826840 2023-08-16T05:22:05 Z ttamx 드문 곤충 (IOI22_insects) C++17
0 / 100
1 ms 336 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

int min_cardinality(int n){
	vector<int> single,cur;
	for(int i=0;i<n;i++){
		move_inside(i);
		if(press_button()>1){
			cur.emplace_back(i);
			move_outside(i);
		}else{
			single.emplace_back(i);
		}
	}
	for(auto i:single)move_outside(i);
	int k=single.size()-1;
	int l=1,r=n/k;
	int cnt=0;
	while(l<r){
		int m=(l+r+1)/2;
		vector<int> vl,vr;
		for(auto i:cur){
			if(vl.size()+cnt==k*m){
				vr.emplace_back(i);
				continue;
			}
			move_inside(i);
			if(press_button()>m){
				vr.emplace_back(i);
				move_outside(i);
			}else{
				vl.emplace_back(i);
			}
		}
		if(vl.size()+cnt==k*m){
			l=m;
			cnt+=vl.size();
			cur=vr;
		}else{
			r=m-1;
			for(auto i:vl)move_outside(i);
			cur=vl;
		}
	}
	return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:25:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |    if(vl.size()+cnt==k*m){
      |       ~~~~~~~~~~~~~^~~~~
insects.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |   if(vl.size()+cnt==k*m){
      |      ~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 1 ms 336 KB Execution killed with signal 8
3 Halted 0 ms 0 KB -