Submission #826958

# Submission time Handle Problem Language Result Execution time Memory
826958 2023-08-16T07:30:50 Z ttamx Rarest Insects (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;
	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(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;
		}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:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i=1;i<cur.size();i++){
      |               ~^~~~~~~~~~~
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){
      |      ~~~~~~~~~~~~~^~~~~
insects.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    for(int i=1;i<vl.size();i++)move_outside(vl[i]);
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 1 ms 336 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -