제출 #838202

#제출 시각아이디문제언어결과실행 시간메모리
838202Dremix10드문 곤충 (IOI22_insects)C++17
10 / 100
313 ms448 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl;
    #define p2(x,y) cerr<<#x<<","<<#y<<" = "<<x<<" ,"<<y<<endl;
#else
    #define p(x) {}
    #define pv(x) {}
    #define p2(x,y) {}
#endif



int min_cardinality(int N) {

    int i;
    multiset<int> s;
    int curr = 1;
    s.insert(0);
    move_inside(0);
    bool in[N];
    p2(1,0)
    int arr[N];
    arr[0] = 0;
    int j;
    in[0] = true;

    for(i=1;i<N;i++){
        move_inside(i);
        p2(1,i)
        in[i] = true;
        int x = press_button();
        if(x == 1){
            s.insert(curr);
            arr[i] = curr;
            curr++;
        }
        else{
            //assert(x == 2);
            bool ok =false;
            p(i)
            for(j=i-1;j>=0;j--){
                if(!in[j])continue;
                move_outside(j);
                in[j] = false;
                p2(2,j)
                x = press_button();
                if(x == 1){
                    arr[i] = arr[j];
                    s.insert(arr[i]);
                    ok = true;
                    break;
                }
                p2(1,j)
                move_inside(j);
                in[j] = true;
            }
            assert(ok);
        }
    }
    int ret = N;
    for(auto x : s){
        ret = min(ret,(int)s.count(x));
    }
    return ret; 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...