Submission #711123

#TimeUsernameProblemLanguageResultExecution timeMemory
711123PoonYaPatRarest Insects (IOI22_insects)C++17
0 / 100
3069 ms208 KiB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

queue<int> out,in,temp,temp2;
int type;

int min_cardinality(int n) {
    for (int i=0; i<n; ++i) {
        move_inside(i); //move in
        if (press_button()>1) move_outside(i), out.push(i);
        else ++type, in.push(i);
    }

    int bound=n/type;
    while (1) {
        //check whether ans is less than bound or not

        while (!out.empty()) {
            move_inside(out.front()); //move in

            if (press_button()>bound) move_outside(out.front()), temp2.push(out.front()); //move out
            else temp.push(out.front());
            out.pop();

            if (in.size()+temp.size()==type*bound) {
                return bound;
            }
        }
        while (!temp2.empty()) {
            out.push(temp2.front());
            temp2.pop();
        }

        bound=(in.size()+temp.size())/type;

        while (!out.empty()) out.pop();
        while (!temp.empty()) {
            out.push(temp.front());
            move_outside(temp.front()); //move out
            temp.pop();
        }
    }
}

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:26:38: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |             if (in.size()+temp.size()==type*bound) {
      |                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...