답안 #1078046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078046 2024-08-27T11:54:29 Z pcc 드문 곤충 (IOI22_insects) C++17
0 / 100
48 ms 804 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 2022;
vector<int> v[mxn];
set<int> st;
int N;
int cnt = 0;
const int B = 4;
int mx[mxn];

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

void add(int k){
	assert(st.find(k) == st.end());
	st.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(mx[i]>lim)continue;
		if(st.find(i) == st.end()){
			add(i);
			int re = ask();
			mx[i] = max(mx[i],re);
			if(re>lim)del(i);
			else v[re].push_back(i);
		}
	}
	return lim*cnt == st.size();
}

int brute(int N,int cnt){
}

int min_cardinality(int NN) {
	N = NN;
	check(1);
	cnt = st.size();
	int l = 1,r = N/cnt;
	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:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  return lim*cnt == st.size();
      |         ~~~~~~~~^~~~~~~~~~~~
insects.cpp: In function 'int brute(int, int)':
insects.cpp:54:1: warning: no return statement in function returning non-void [-Wreturn-type]
   54 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Incorrect 2 ms 344 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 4 ms 488 KB Output is correct
7 Correct 2 ms 596 KB Output is correct
8 Correct 3 ms 600 KB Output is correct
9 Incorrect 2 ms 344 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 29 ms 804 KB Output is correct
8 Correct 8 ms 344 KB Output is correct
9 Correct 48 ms 600 KB Output is correct
10 Correct 22 ms 588 KB Output is correct
11 Correct 21 ms 592 KB Output is correct
12 Correct 15 ms 600 KB Output is correct
13 Incorrect 24 ms 496 KB Wrong answer.
14 Halted 0 ms 0 KB -