제출 #977475

#제출 시각아이디문제언어결과실행 시간메모리
977475HappyCapybara드문 곤충 (IOI22_insects)C++17
10 / 100
94 ms1416 KiB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;

int min_cardinality(int n){
    vector<int> v;
    vector<int> s(n, 1);
    for (int i=0; i<n; i++) v.push_back(i);
    for (int i=0; i<n-1; i++){
        if (v[i] < i) continue;

        for (int j=0; j<n; j++){
            if (v[j] >= i) move_inside(j);
        }
        int x = press_button();
        for (int j=0; j<n; j++){
            if (v[j] >= i) move_outside(j);
        }
        if (x == 1) break;
        int y = 1;

        move_inside(i);
        for (int j=i+1; j<n; j++){
            if (v[j] < j) continue;
            move_inside(j);
            if (press_button() == 2){
                s[v[j]]--;
                s[v[i]]++;
                v[j] = v[i];
                y++;
                if (y == x) break;
            }
            move_outside(j);
        }
        move_outside(i);
    }
    int bsf = n;
    for (int i=0; i<n; i++){
        if (s[i] != 0) bsf = min(bsf, s[i]);
    }
    return bsf;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...