Submission #1077686

# Submission time Handle Problem Language Result Execution time Memory
1077686 2024-08-27T08:35:35 Z pcc Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 2022;
vector<int> v[mxn];
set<int> machine;
int N;

void del(int k){
	assert(machine.find(k) != machine.end());
	machine.erase(k);
	move_outside(k);
	return;
}

void add(int k){
	assert(machine.find(k) == machine.end());
	machine.insert(k);
	move_inside(k);
	return;
}

int ask(){
	int re = press_button();
	return re;
}

bool check(int lim){
	for(int i = lim+1;i<=N;i++){
		while(!v[i].empty()){
			auto now = v[i].back();
			v[i].pop_back();
			del(now);
		}
	}
	for(int i = 0;i<N;i++){
		if(machine.find(i) == machine.end()){
			add(i);
			int re = ask();
			if(re>lim)del(i);
			v[re].push_back(i);
		}
	}
	return lim*N == machine.size();
}

int min_cardinality(int NN) {
	N = NN;
	int l = 1,r = N;
	while(l != r){
		int mid = (l+r+1)>>1;
		if(check(mid))l = mid;
		else r = mid-1;
	}
	return l;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  return lim*N == machine.size();
      |         ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -