Submission #726828

# Submission time Handle Problem Language Result Execution time Memory
726828 2023-04-19T12:04:09 Z Huseyn123 Rarest Insects (IOI22_insects) C++17
100 / 100
80 ms 6868 KB
#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){
    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
1 Correct 4 ms 6480 KB Output is correct
2 Correct 4 ms 6480 KB Output is correct
3 Correct 4 ms 6480 KB Output is correct
4 Correct 5 ms 6480 KB Output is correct
5 Correct 3 ms 6480 KB Output is correct
6 Correct 8 ms 6480 KB Output is correct
7 Correct 7 ms 6580 KB Output is correct
8 Correct 9 ms 6580 KB Output is correct
9 Correct 10 ms 6584 KB Output is correct
10 Correct 10 ms 6576 KB Output is correct
11 Correct 8 ms 6580 KB Output is correct
12 Correct 8 ms 6480 KB Output is correct
13 Correct 8 ms 6480 KB Output is correct
14 Correct 6 ms 6480 KB Output is correct
15 Correct 10 ms 6572 KB Output is correct
16 Correct 9 ms 6580 KB Output is correct
17 Correct 9 ms 6576 KB Output is correct
18 Correct 16 ms 6460 KB Output is correct
19 Correct 9 ms 6576 KB Output is correct
20 Correct 7 ms 6580 KB Output is correct
21 Correct 7 ms 6580 KB Output is correct
22 Correct 6 ms 6548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6480 KB Output is correct
2 Correct 4 ms 6480 KB Output is correct
3 Correct 4 ms 6480 KB Output is correct
4 Correct 5 ms 6480 KB Output is correct
5 Correct 3 ms 6480 KB Output is correct
6 Correct 8 ms 6480 KB Output is correct
7 Correct 7 ms 6580 KB Output is correct
8 Correct 9 ms 6580 KB Output is correct
9 Correct 10 ms 6584 KB Output is correct
10 Correct 10 ms 6576 KB Output is correct
11 Correct 8 ms 6580 KB Output is correct
12 Correct 8 ms 6480 KB Output is correct
13 Correct 8 ms 6480 KB Output is correct
14 Correct 6 ms 6480 KB Output is correct
15 Correct 10 ms 6572 KB Output is correct
16 Correct 9 ms 6580 KB Output is correct
17 Correct 9 ms 6576 KB Output is correct
18 Correct 16 ms 6460 KB Output is correct
19 Correct 9 ms 6576 KB Output is correct
20 Correct 7 ms 6580 KB Output is correct
21 Correct 7 ms 6580 KB Output is correct
22 Correct 6 ms 6548 KB Output is correct
23 Correct 27 ms 6576 KB Output is correct
24 Correct 11 ms 6608 KB Output is correct
25 Correct 28 ms 6580 KB Output is correct
26 Correct 30 ms 6600 KB Output is correct
27 Correct 35 ms 6600 KB Output is correct
28 Correct 9 ms 6596 KB Output is correct
29 Correct 36 ms 6580 KB Output is correct
30 Correct 34 ms 6580 KB Output is correct
31 Correct 19 ms 6584 KB Output is correct
32 Correct 24 ms 6616 KB Output is correct
33 Correct 27 ms 6572 KB Output is correct
34 Correct 36 ms 6568 KB Output is correct
35 Correct 37 ms 6576 KB Output is correct
36 Correct 22 ms 6600 KB Output is correct
37 Correct 32 ms 6584 KB Output is correct
38 Correct 34 ms 6592 KB Output is correct
39 Correct 17 ms 6580 KB Output is correct
40 Correct 23 ms 6604 KB Output is correct
41 Correct 14 ms 6600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6480 KB Output is correct
2 Correct 5 ms 6500 KB Output is correct
3 Correct 5 ms 6480 KB Output is correct
4 Correct 4 ms 6480 KB Output is correct
5 Correct 4 ms 6480 KB Output is correct
6 Correct 5 ms 6568 KB Output is correct
7 Correct 51 ms 6708 KB Output is correct
8 Correct 24 ms 6644 KB Output is correct
9 Correct 56 ms 6736 KB Output is correct
10 Correct 59 ms 6612 KB Output is correct
11 Correct 54 ms 6592 KB Output is correct
12 Correct 35 ms 6720 KB Output is correct
13 Correct 49 ms 6608 KB Output is correct
14 Correct 75 ms 6580 KB Output is correct
15 Correct 47 ms 6720 KB Output is correct
16 Correct 55 ms 6728 KB Output is correct
17 Correct 76 ms 6716 KB Output is correct
18 Correct 49 ms 6720 KB Output is correct
19 Correct 58 ms 6712 KB Output is correct
20 Correct 53 ms 6720 KB Output is correct
21 Correct 70 ms 6712 KB Output is correct
22 Correct 76 ms 6668 KB Output is correct
23 Correct 31 ms 6588 KB Output is correct
24 Correct 60 ms 6660 KB Output is correct
25 Correct 48 ms 6612 KB Output is correct
26 Correct 34 ms 6608 KB Output is correct
27 Correct 57 ms 6776 KB Output is correct
28 Correct 53 ms 6740 KB Output is correct
29 Correct 60 ms 6744 KB Output is correct
30 Correct 49 ms 6724 KB Output is correct
31 Correct 80 ms 6708 KB Output is correct
32 Correct 68 ms 6696 KB Output is correct
33 Correct 54 ms 6628 KB Output is correct
34 Correct 58 ms 6580 KB Output is correct
35 Correct 41 ms 6740 KB Output is correct
36 Correct 52 ms 6720 KB Output is correct
37 Correct 44 ms 6708 KB Output is correct
38 Correct 76 ms 6616 KB Output is correct
39 Correct 72 ms 6868 KB Output is correct
40 Correct 78 ms 6708 KB Output is correct
41 Correct 60 ms 6744 KB Output is correct
42 Correct 58 ms 6720 KB Output is correct
43 Correct 20 ms 6572 KB Output is correct
44 Correct 61 ms 6588 KB Output is correct
45 Correct 46 ms 6748 KB Output is correct
46 Correct 19 ms 6600 KB Output is correct
47 Correct 24 ms 6600 KB Output is correct
48 Correct 32 ms 6660 KB Output is correct