Submission #1070065

# Submission time Handle Problem Language Result Execution time Memory
1070065 2024-08-22T11:27:01 Z Unforgettablepl Rarest Insects (IOI22_insects) C++17
0 / 100
67 ms 436 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N){
    vector<int> uniques = {0};
    move_inside(0);
    vector<bool> isCommon(N);
    vector<int> ans(N,-1);
    ans[0]=1;
    for(int i=1;i<N;i++) {
        move_inside(i);
        if(press_button()==1) {
            uniques.emplace_back(i);
            ans[i]=1;
        } else {
            move_outside(i);
            isCommon[i]=true;
        }
    }
    for(int&i:uniques)move_outside(i);
    for(int jump=1024;jump;jump/=2) {
        vector<pair<int,int>> queries;
        for(int i=0;i<N;i++)if(isCommon[i]) {
            if(ans[i]+jump>=uniques.size()-1)continue;
            queries.emplace_back(ans[i]+jump,i);
        }
        int added = -1;
        sort(queries.begin(),queries.end());
        for(auto&[x,idx]:queries) {
            while(added<x)move_inside(uniques[++added]);
            while(added>x)move_outside(uniques[--added]);
            move_inside(idx);
            if(press_button()==1)ans[idx]=x;
            move_outside(idx);
        }
    }
    for(int i=0;i<N;i++)if(isCommon[i])ans[uniques[ans[i]+1]]++;
    int siz = N;
    for(int i=0;i<N;i++)if(!isCommon[i])siz=min(siz,ans[i]);
    return siz;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:25:27: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if(ans[i]+jump>=uniques.size()-1)continue;
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 5 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Incorrect 5 ms 344 KB Wrong answer.
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 8 ms 344 KB Output is correct
8 Correct 10 ms 344 KB Output is correct
9 Incorrect 67 ms 436 KB Wrong answer.
10 Halted 0 ms 0 KB -