Submission #1058140

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10581402024-08-14 08:40:35Dan4LifeRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#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;
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++;
}
if(tot==D*mid) l = mid;
else{
for(int i = 0; i < n; i++)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:24:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |             if(inside[i]) continue; move_inside(i);
      |             ^~
insects.cpp:24:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   24 |             if(inside[i]) continue; move_inside(i);
      |                                     ^~~~~~~~~~~
insects.cpp:31:28: error: 'u' was not declared in this scope
   31 |                 if(!inside[u]) inside[u]=-1;
      |                            ^