답안 #726754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
726754 2023-04-19T10:09:46 Z Huseyn123 드문 곤충 (IOI22_insects) C++17
100 / 100
63 ms 6748 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){
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6480 KB Output is correct
2 Correct 3 ms 6480 KB Output is correct
3 Correct 4 ms 6480 KB Output is correct
4 Correct 4 ms 6480 KB Output is correct
5 Correct 3 ms 6480 KB Output is correct
6 Correct 7 ms 6480 KB Output is correct
7 Correct 4 ms 6580 KB Output is correct
8 Correct 8 ms 6480 KB Output is correct
9 Correct 9 ms 6580 KB Output is correct
10 Correct 8 ms 6480 KB Output is correct
11 Correct 6 ms 6480 KB Output is correct
12 Correct 8 ms 6480 KB Output is correct
13 Correct 10 ms 6480 KB Output is correct
14 Correct 8 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 9 ms 6480 KB Output is correct
17 Correct 8 ms 6576 KB Output is correct
18 Correct 9 ms 6584 KB Output is correct
19 Correct 8 ms 6480 KB Output is correct
20 Correct 7 ms 6580 KB Output is correct
21 Correct 7 ms 6480 KB Output is correct
22 Correct 6 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6480 KB Output is correct
2 Correct 3 ms 6480 KB Output is correct
3 Correct 4 ms 6480 KB Output is correct
4 Correct 4 ms 6480 KB Output is correct
5 Correct 3 ms 6480 KB Output is correct
6 Correct 7 ms 6480 KB Output is correct
7 Correct 4 ms 6580 KB Output is correct
8 Correct 8 ms 6480 KB Output is correct
9 Correct 9 ms 6580 KB Output is correct
10 Correct 8 ms 6480 KB Output is correct
11 Correct 6 ms 6480 KB Output is correct
12 Correct 8 ms 6480 KB Output is correct
13 Correct 10 ms 6480 KB Output is correct
14 Correct 8 ms 6480 KB Output is correct
15 Correct 7 ms 6480 KB Output is correct
16 Correct 9 ms 6480 KB Output is correct
17 Correct 8 ms 6576 KB Output is correct
18 Correct 9 ms 6584 KB Output is correct
19 Correct 8 ms 6480 KB Output is correct
20 Correct 7 ms 6580 KB Output is correct
21 Correct 7 ms 6480 KB Output is correct
22 Correct 6 ms 6480 KB Output is correct
23 Correct 17 ms 6576 KB Output is correct
24 Correct 11 ms 6604 KB Output is correct
25 Correct 26 ms 6624 KB Output is correct
26 Correct 35 ms 6600 KB Output is correct
27 Correct 25 ms 6480 KB Output is correct
28 Correct 14 ms 6584 KB Output is correct
29 Correct 33 ms 6568 KB Output is correct
30 Correct 26 ms 6588 KB Output is correct
31 Correct 27 ms 6624 KB Output is correct
32 Correct 28 ms 6600 KB Output is correct
33 Correct 22 ms 6600 KB Output is correct
34 Correct 19 ms 6612 KB Output is correct
35 Correct 29 ms 6584 KB Output is correct
36 Correct 31 ms 6600 KB Output is correct
37 Correct 20 ms 6588 KB Output is correct
38 Correct 25 ms 6592 KB Output is correct
39 Correct 23 ms 6596 KB Output is correct
40 Correct 14 ms 6608 KB Output is correct
41 Correct 13 ms 6580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6480 KB Output is correct
2 Correct 3 ms 6480 KB Output is correct
3 Correct 3 ms 6480 KB Output is correct
4 Correct 3 ms 6480 KB Output is correct
5 Correct 4 ms 6480 KB Output is correct
6 Correct 4 ms 6480 KB Output is correct
7 Correct 47 ms 6712 KB Output is correct
8 Correct 24 ms 6720 KB Output is correct
9 Correct 52 ms 6740 KB Output is correct
10 Correct 57 ms 6600 KB Output is correct
11 Correct 55 ms 6600 KB Output is correct
12 Correct 38 ms 6668 KB Output is correct
13 Correct 48 ms 6592 KB Output is correct
14 Correct 51 ms 6580 KB Output is correct
15 Correct 49 ms 6724 KB Output is correct
16 Correct 52 ms 6712 KB Output is correct
17 Correct 50 ms 6708 KB Output is correct
18 Correct 57 ms 6728 KB Output is correct
19 Correct 45 ms 6716 KB Output is correct
20 Correct 51 ms 6736 KB Output is correct
21 Correct 60 ms 6632 KB Output is correct
22 Correct 51 ms 6728 KB Output is correct
23 Correct 46 ms 6592 KB Output is correct
24 Correct 48 ms 6600 KB Output is correct
25 Correct 28 ms 6732 KB Output is correct
26 Correct 13 ms 6608 KB Output is correct
27 Correct 52 ms 6700 KB Output is correct
28 Correct 40 ms 6728 KB Output is correct
29 Correct 53 ms 6712 KB Output is correct
30 Correct 52 ms 6716 KB Output is correct
31 Correct 63 ms 6688 KB Output is correct
32 Correct 31 ms 6588 KB Output is correct
33 Correct 42 ms 6644 KB Output is correct
34 Correct 60 ms 6624 KB Output is correct
35 Correct 53 ms 6748 KB Output is correct
36 Correct 46 ms 6728 KB Output is correct
37 Correct 43 ms 6616 KB Output is correct
38 Correct 50 ms 6688 KB Output is correct
39 Correct 36 ms 6720 KB Output is correct
40 Correct 61 ms 6704 KB Output is correct
41 Correct 44 ms 6732 KB Output is correct
42 Correct 38 ms 6720 KB Output is correct
43 Correct 16 ms 6580 KB Output is correct
44 Correct 45 ms 6576 KB Output is correct
45 Correct 33 ms 6708 KB Output is correct
46 Correct 28 ms 6608 KB Output is correct
47 Correct 26 ms 6660 KB Output is correct
48 Correct 23 ms 6624 KB Output is correct