Submission #630956

#TimeUsernameProblemLanguageResultExecution timeMemory
630956blueRarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include <vector> #include <iostream> using namespace std; using vi = vector<int>; using vvi = vector<vi>; const int mx = 2'000; vi ins(mx, 0); int ct = 0; void move_in(int i) { if(ins[i]) return; ins[i] = 1; move_inside(i); ct++; } void move_out(int i) { if(!ins[i]) return; ins[i] = 0; move_outside(i); ct--; } int min_cardinality(int N) { int tot = 0; vi is_basic(N, 0); for(int i = 0; i < N; i++) { move_inside(i); if(press_button() >= 2) move_outside(i); else { is_basic[i] = 1; tot++; } } // cerr << "tot = " << tot << '\n'; int uplim = 1; for(int e = 11; e >= 0; e--) { int newlim = uplim + (1<<e); for(int i = 0; i < N; i++) move_out(i); for(int i = 0; i < N; i++) { move_in(i); if(press_button() > uplim) move_out(i); } if(ct == tot * mid) uplim += (1<<e); } return uplim; }

Compilation message (stderr)

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:70:18: error: 'mid' was not declared in this scope
   70 |   if(ct == tot * mid)
      |                  ^~~
insects.cpp:58:7: warning: unused variable 'newlim' [-Wunused-variable]
   58 |   int newlim = uplim + (1<<e);
      |       ^~~~~~