This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include <bits/stdc++.h>
#define MAX 200001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
for(int i=0;i<b;i++){\
cin >> a[i];\
}\
}
#define inputvec(a,b){\
for(int i=0;i<b;i++){\
ll num;\
cin >> num;\
a.pb(num);\
}\
}
#define outputar(a,b){\
for(int i=0;i<b;i++){\
cout << a[i] << " ";\
}\
cout << "\n";\
}
#define outputvec(a){\
for(auto x:a){\
cout << x << " ";\
}\
cout << "\n";\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
freopen((filename+".in").c_str(),"r",stdin);
freopen((filename+".out").c_str(),"w",stdout);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n,q,t=1,m,n2,m2,k,cnt=0,a[MAX],b[MAX],d[MAX],d2[MAX],x,y,z,x2,y2,z2,res1=0,cnt1,cnt2,cnt3;
ll c[1001][1001];
ll c2[1001][1001];
ll fact[MAX];
ll inv_fact[MAX];
//char c;
string str[MAX];
string s1,s2;
const int mod = 998244353;
vector<ll> vec;
set<ll> st1,st2,st3;
int h=0;
int h2=0;
bool f(int v){
shuffle(all(vec),rng);
ll cnt=st3.size();
for(int i=0;i<n;i++){
if(cnt==v*h){
break;
}
if(st3.find(vec[i])!=st3.end()){
continue;
}
if(st2.find(vec[i])!=st2.end()){
continue;
}
move_inside(vec[i]);
st1.ins(vec[i]);
ll ans=press_button();
if(ans>v){
move_outside(vec[i]);
st1.erase(vec[i]);
}
else{
cnt++;
}
}
h2=v;
//cout << v << " " << cnt << "\n";
if(cnt!=v*h){
for(int i=0;i<n;i++){
if(st1.find(vec[i])==st1.end()){
st2.ins(vec[i]);
}
}
for(auto x:st1){
if(st3.find(x)==st3.end()){
move_outside(x);
}
}
st1.clear();
}
else{
for(auto x:st1){
st3.ins(x);
}
}
return cnt==v*h;
}
int min_cardinality(int N) {
n=N;
for(int i=0;i<n;i++){
vec.pb(i);
}
shuffle(all(vec),rng);
for(int i=0;i<n;i++){
move_inside(vec[i]);
st1.ins(vec[i]);
ll ans=press_button();
if(ans>1){
move_outside(vec[i]);
st1.erase(vec[i]);
}
else if(ans==1){
h++;
}
}
st3=st1;
//cout << h << "\n";
int l,r,mid;
l=1;
r=N/h;
while(l<r){
mid=(l+r+1)/2;
if(f(mid)){
l=mid;
}
else{
r=mid-1;
}
}
return r;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |