Submission #859000

#TimeUsernameProblemLanguageResultExecution timeMemory
859000thinknoexitRarest Insects (IOI22_insects)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
using ll = long long;
bool in[2020];
int min_cardinality(int n) {
    int type = 0;
    for (int i = 0;i < n;i++) {
        move_inside(i);
        if (press_button() == 2) {
            move_outside(i);
        }
        else in[i] = 1, type++;
    }
    for (int i = 0;i < n;i++) if (in[i]) move_outside(i);
    if (type == 1) return n;
    int mxans = n / type;
    for (int i = 2;i <= mxans;i++) {
        int cnt = 0;
        for (int j = 0;j < n;j++) {
            if (in[j]) continue;
            move_inside(j);
            if (press_button() == 2) {
                move_outside(j);
            }
            else in[j] = 1, cnt++;
        }
        if (cnt != type) return i - 1;
    }
    return -1;
    // n , n , n
    /*
        ans <= n / type
        ans <= n - mx
    */

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...