답안 #826964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826964 2023-08-16T07:33:02 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=1;i<n;i++){
		move_inside(i);
		if(press_button()>1){
			cur.emplace_back(i);
			move_outside(i);
		}else{
			single.emplace_back(i);
		}
	}
	int k=single.size();
	int l=1,r=n/k;
	int cnt=k;
	move_inside(cur[0]);
	while(l<r){
		int m=(l+r+1)/2;
		vector<int> vl,vr;
		vl.emplace_back(cur[0]);
		for(int i=1;i<cur.size();i++){
			if(vl.size()+cnt==k*m){
				vr.emplace_back(cur[i]);
				continue;
			}
			move_inside(cur[i]);
			if(press_button()>m){
				vr.emplace_back(cur[i]);
				move_outside(cur[i]);
			}else{
				vl.emplace_back(cur[i]);
			}
		}
		if(vl.size()+cnt==k*m){
			l=m;
			cnt+=vl.size();
			cur=vr;
			move_inside(cur[0]);
		}else{
			r=m-1;
			for(int i=1;i<vl.size();i++)move_outside(vl[i]);
			cur=vl;
		}
	}
	return l;
}

Compilation message

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