Submission #1058132

# Submission time Handle Problem Language Result Execution time Memory
1058132 2024-08-14T08:39:05 Z Dan4Life Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
using vi = vector<int>;
int D, inside[3000];

int min_cardinality(int n) {
    for(int i = 0; i < n; i++){
        move_inside(i);
        if(press_button()>1) move_outside(i);
        else inside[i]=1, D++;
    }
    if(D==1) return n;
    int l = 2, r = n/D, p=1, tot=D;
    while(l<r){
        int mid = (l+r+1)/2;
        vi undo; undo.clear();
        for(int i = 0; i < n; i++)
            if(inside[i] > mid and mid<p)
                move_outside(i), inside[i]=0, tot--;
        for(int i = 0; i < n; i++){
            if(inside[i]) continue; move_inside(i);
            if(press_button()>mid) move_outside(i);
            else inside[i]=mid, tot++, undo.pb(i);
        }
        if(tot==D*mid) l = mid;
        else{
            for(auto u : undo) inside[u]=-1;
            r=mid-1;
        }
        p=mid;
    }
    return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:25:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |             if(inside[i]) continue; move_inside(i);
      |             ^~
insects.cpp:25:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   25 |             if(inside[i]) continue; move_inside(i);
      |                                     ^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong answer.
3 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 -