#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());
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(i);
move_inside(i);
};
auto del = [&](int i) -> void{
s.erase(i);
move_outside(i);
};
auto check = [&](int k) -> int{
nw.clear();
auto op=*mp.lower_bound(k);
for(auto i:op.second){
if(s.find(i)!=s.end()) continue;
add(i);
if(press_button()>k) del(i);
else nw.push_back(i);
}
mp[k]=s;
if((int)s.size()==cad*k) return 711;
return (int)s.size()>cad*k;
};
for(int i=0; i<n; i++){
add(p[i]);
if(press_button()>1) del(p[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;
int v=check(mid);
if(v==711) return mid;
if(v){
ans=mid;
l=mid+1;
}else{
r=mid-1;
for(auto i:nw) del(i);
}
}
return ans;
}
/** /\_/\
* (= ._.)
* / >💖 \>💕
**/
Compilation message
insects.cpp:70:9: warning: "/*" within comment [-Wcomment]
70 | /** /\_/\
|
# |
결과 |
실행 시간 |
메모리 |
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 |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
2 ms |
600 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Incorrect |
2 ms |
600 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
Incorrect |
1 ms |
344 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |