Submission #988560

# Submission time Handle Problem Language Result Execution time Memory
988560 2024-05-25T07:16:01 Z cnn008 Rarest Insects (IOI22_insects) C++17
0 / 100
41 ms 1972 KB
#include "bits/stdc++.h"
using namespace std;

#include "insects.h"

#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif

#define ll long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    assert(l<=r);
    return uniform_int_distribution<int> (l,r)(rng);
}

const int N=1e5+5;
const int mod=1e9+7;

int min_cardinality(int n){
	set <int> s;
	vector <int> nw;
	vector <int> p(n);
	iota(p.begin(),p.end(),0);
	shuffle(p.begin(),p.end(),rng);
	map <int,set<int>> mp;
	int cad;
	auto add = [&](int i) -> void{
		s.insert(p[i]);
		move_inside(p[i]);
	};
	auto del = [&](int i) -> void{
		s.erase(p[i]);
		move_outside(p[i]);
	};
	auto check = [&](int k) -> bool{
		nw.clear();
		auto op=*mp.lower_bound(k);
		for(auto i:op.second){
			if(s.find(p[i])!=s.end()) continue;
			add(i);
			if(press_button()>k) del(i);
			else nw.push_back(p[i]);
		}
		mp[k]=s;
		return (int)s.size()>=cad*k;
	};
	for(int i=0; i<n; i++){
		add(i);
		if(press_button()>1) del(i);
	}
	cad=(int)s.size();
	mp[1]=s;
	for(int i=0; i<n; i++) mp[n].insert(i);
	int l=2,r=n/cad,ans=1;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)){
			ans=mid;
			l=mid+1;
		}else{
			r=mid-1;
			for(auto i:nw) del(i);
		}
	}
	return ans;
}
/**  /\_/\
*   (= ._.)
*   / >💖 \>💕
**/

Compilation message

insects.cpp:71:9: warning: "/*" within comment [-Wcomment]
   71 | /**  /\_/\
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 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 3 ms 600 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 880 KB Output is correct
10 Incorrect 4 ms 856 KB Wrong answer.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 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 3 ms 600 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 880 KB Output is correct
10 Incorrect 4 ms 856 KB Wrong answer.
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 33 ms 1972 KB Output is correct
8 Correct 9 ms 1120 KB Output is correct
9 Correct 38 ms 1444 KB Output is correct
10 Incorrect 41 ms 1484 KB Wrong answer.
11 Halted 0 ms 0 KB -