Submission #1173686

#TimeUsernameProblemLanguageResultExecution timeMemory
1173686SpyrosAlivRarest Insects (IOI22_insects)C++20
10 / 100
99 ms420 KiB
#include <bits/stdc++.h>
using namespace std;

void move_inside(int x);
void move_outside(int x);
int press_button();

int min_cardinality(int n) {
    vector<int> lvl;
    int comps = 0;
    vector<bool> added(n, false);
    for (int i = 0; i < n; i++) {
        move_inside(i);
        int x = press_button();
        if (x == 1) {
            comps++;
            added[i] = true;
        }
        else {
            move_outside(i);
            lvl.push_back(i);
        }
    }
    int fin = 1;
    for (int curr = 2; curr <= n / comps; curr++) {
        int tot = 0;
        for (int i = 0; i < n; i++) {
            if (added[i]) continue;
            move_inside(i);
            int x = press_button();
            if (x == curr) {
                added[i] = true;
                tot++;
            }
            else {
                move_outside(i);
            }
        }
        if (tot != comps) {
            break;
        }
        fin = curr;
    }
    return fin;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...