Submission #977465

# Submission time Handle Problem Language Result Execution time Memory
977465 2024-05-08T03:09:12 Z SiliconSquared Rarest Insects (IOI22_insects) C++17
0 / 100
190 ms 588 KB
#include "insects.h"
using namespace std;
#include <vector>
int min_cardinality(int N) {
    int a,b,c,q;
    vector<bool> g;
    vector<bool> h;
    bool f;
    g.resize(N,false);
    h.resize(N);
    for (int i=0;i<N;i++){
        move_inside(i);
    }
    b=press_button();
    for (int i=0;i<N;i++){
        move_outside(i);
    }
    a=1;
    while (a!=b){
        c=(a+b)/2;
        for (int i=0;i<N;i++){h[i]=false;}
        for (int i=0;i<N;i++){
            if (!g[i]){
                move_inside(i);
                q=press_button();
                if (q>c){
                    move_outside(i);
                    h[i]=true;
                }
            }
        }
        for (int i=0;i<N;i++){
            if (!g[i]){
                if (h[i]){
                    move_inside(i);
                    if (press_button()==2){
                        move_outside(i);
                    }
                }else{
                    move_outside(i);
                }
            }
        }
        f=true;
        for (int i=0;i<N;i++){
            if ((!g[i])&&(!h[i])){
                move_inside(i);
                if (press_button()==2){
                    h[i]=true;
                }else{
                    f=false;
                }
                move_outside(i);
            }
        }
        if (f){
            //all bugs eliminated
            a=c+1;
        }else{
            //some bugs remain
            b=c;
            for (int i=0;i<N;i++){
                if (h[i]){
                    g[i]=true;
                }
            }
        }
    }
    return a;
}
# 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 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 13 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 4 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 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 13 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 4 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 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Partially correct 0 ms 344 KB Output is partially correct
6 Partially correct 0 ms 344 KB Output is partially correct
7 Incorrect 190 ms 588 KB Too many queries.
8 Halted 0 ms 0 KB -