제출 #838220

#제출 시각아이디문제언어결과실행 시간메모리
838220Dremix10드문 곤충 (IOI22_insects)C++17
10 / 100
316 ms300 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,ret = 1;
    vector<int> p1,p2,p3;

    for(i=0;i<n;i++){
        move_inside(i);
        int x = press_button();
        if(x == 1){
            p1.push_back(i);
        }
        else{
            assert(x == 2);
            p2.push_back(i);
            move_outside(i);
        }
    }

    while(1){


        /// we have p1 with all the colors (uniquely)
        vector<int> neo;
        pv(p1)
        pv(p2)

        for(auto v : p2){
            move_inside(v);
            int x = press_button();
            if(x == ret + 1){
                neo.push_back(v);
            }
            else{
                assert(x == ret + 2);
                p3.push_back(v);
                move_outside(v);
            }
        }

        p2 = neo;
        pv(p2)
        pv(p3)
        /// we have p2 with all colors that have +1 occurence
        assert(p2.size() <= p1.size());
        if(p2.size() < p1.size())return ret;
        ret ++;

        /// in the machine atm there are all of the colours 2 times each

        p1 = p2;
        p2 = p3;
        p3.clear();
    }
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...