제출 #1369278

#제출 시각아이디문제언어결과실행 시간메모리
1369278huangallen드문 곤충 (IOI22_insects)C++20
60.03 / 100
30 ms488 KiB
#include "insects.h"
#ifdef LOCAL
#include "stub.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define iint signed 
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define RREP1(i,n) for(int i=(n);i>=1;i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)((x).size()))
#define pii pair<int,int>
#define Graph vector<vector<int>>
#define Graphw vector<vector<pii>>
template<typename S> void chmin(S &x,S y) { x=min(x,y); }
template<typename S> void chmax(S &x,S y) { x=max(x,y); }
#define Vi vector<int>
#define Vpii vector<pii>
#ifdef LOCAL
#define op(x) cout<<(#x)<<"="<<(x)<<", ";
#define ope(x) cout<<(#x)<<"="<<(x)<<endl;
#define oparr(x) {cout<<(#x)<<":";for(auto allen:(x)) cout<<allen<<" ";cout<<" size="<<(x).size()<<endl;}
#define entr cout<<endl;
#else
#define op(x) ;
#define ope(x) ;
#define oparr(x) ;
#define entr ;
#endif
template<typename S>
ostream& operator<<(ostream& os,vector<S> p) { for(auto allen:p) os<<allen<<' ';return os<<'\n'; }
template<typename S>
istream& operator>>(istream& os,vector<S> &p) { for(auto &allen:p) os>>allen;return os; }
multiset<int> box;
void movein(int i) { box.insert(i);move_inside(i); }
void moveout(int i) { box.erase(box.find(i));move_outside(i); }
int press() { return press_button(); }
iint min_cardinality(iint N) {
    int n=N;
    Vi a,b;
    movein(0);
    a.pb(0);
    REP1(i,n-1) {
        movein(i);
        if(press()==2) {
            moveout(i);
            b.pb(i);
        }else {
            a.pb(i);
        }
    }
    for(int x:a) moveout(x);
    int m=SZ(a);
    int lgm=__lg(m)+1;
    Vi an(n);
    REP(i,m) an[a[i]]=i;
    Vi inb(m);
    oparr(a)oparr(b)op(m)ope(lgm)
    REP(i,lgm) {
        ope(i)
        REP(j,m) {
            if(j>>i&1) {
                if(!inb[j]) movein(a[j]),inb[j]=1;
            }else {
                if(inb[j]) moveout(a[j]),inb[j]=0;
            }
        }
        oparr(inb)
        ope(i)
        oparr(box)
        REP(j,SZ(b)) {
            movein(b[j]);
            op(b[j])ope(press())
            if(press()==2) an[b[j]]+=1<<i;
            moveout(b[j]);
        }
    }
    ope("ok")
    oparr(an)
    Vi cnt(m);
    REP(i,n) cnt[an[i]]++;
    return *min_element(ALL(cnt));
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…