Submission #1211987

#TimeUsernameProblemLanguageResultExecution timeMemory
1211987serkanrashidRarest Insects (IOI22_insects)C++20
0 / 100
0 ms412 KiB
#include "insects.h"
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

const int MAXN = 2048;
int n;
int used[MAXN];

bool cmp(pair<int,int> p1, pair<int,int> p2)
{
    return p1.second < p2.second;
}
int min_cardinality(int N)
{
    n = N;

    int ans = 1e9;


    vector<pair<int,int> >p;

    for(int i = 0; i < n; i++)
    {
        move_inside(i);
        bool f = false;
        for(int j = 0; j < p.size(); j++)
        {
            pair<int,int>nb = p[j];
            move_inside(nb.second);
            int pb = press_button();
            move_outside(nb.second);

            if(pb == 2)
            {
                nb.first++;
                nb.second  = i;
                p[j] = nb;
                f = true;
            }
            if(f) break;
        }
        if(!f) p.push_back({1,i});
        move_outside(i);

        sort(p.begin(),p.end(),cmp);

        //cout << "after i : " << i << endl;
        //for(pair<int,int> nb : p) cout << nb.first << " " << nb.second << endl;
    }

    return p.back().first;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...