Submission #1056198

# Submission time Handle Problem Language Result Execution time Memory
1056198 2024-08-13T08:12:01 Z vjudge1 Rarest Insects (IOI22_insects) C++17
0 / 100
1 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;
using ii = pair<int, int>;

bool gasit = false;

vector<ii> cauta(vi Cul, vi V) {
    vector<ii> Re;
    if(gasit || V.empty()) return Re;
    if(Cul.size() == 1) {
        if(V.size() == 1) {
            gasit = true;
            return vector<ii>();
        }
        for(auto it : V) Re.push_back({it, Cul[0]});
        return Re;
    }
    vi C1, C2;
    for(int i = 0; i < int(Cul.size()) / 2; ++i) {
        C1.push_back(Cul[i]);
    }
    for(int i = int(Cul.size()) / 2; i < int(Cul.size()); ++i) {
        C2.push_back(Cul[i]);
    }
    for(auto it : C1) {
        move_inside(it);
    }
    vi V1, V2;
    for(auto it : V) {
        move_inside(it);
        if(press_button() == 2) V1.push_back(it);
        else V2.push_back(it);
        move_outside(it);
    }
    for(auto it : C1) {
        move_outside(it);
    }

    auto Re1 = cauta(C1, V1), Re2 = cauta(C2, V2);
    for(auto it : Re1) Re.push_back(it);
    for(auto it : Re2) Re.push_back(it);
    return Re;
}

int min_cardinality(int n) {
    vi Cul, Rest;
    for(int i = 0; i < n; ++i) {
        move_inside(i);
        if(press_button() == 1) {
            Cul.push_back(i);
        } else {
            move_outside(i);
            Rest.push_back(i);
        }
    }
    for(auto it : Cul) move_outside(it);
    if(Cul.size() > Rest.size()) return 1;
    auto Per = cauta(Cul, Rest);
    if(gasit) return 1;
    map<int, int> Fr;
    for(auto it : Cul) ++Fr[it];
    for(auto [p, cul] : Per) ++Fr[cul];
    int mi = n;
    for(auto [cul, fr] : Fr) mi = min(mi, fr);
    return mi;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -