Submission #630967

#TimeUsernameProblemLanguageResultExecution timeMemory
630967blueRarest Insects (IOI22_insects)C++17
45.45 / 100
258 ms636 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_in(i); if(press_button() >= 2) move_out(i); else { is_basic[i] = 1; tot++; } } for(int i = 0; i < N; i++) move_out(i); // cerr << "tot = " << tot << '\n'; int uplim = 1; for(int e = 11; e >= 0; e--) { int newlim = uplim + (1<<e); vi currlist; for(int i = 0; i < N; i++) { if(ins[i]) continue; move_in(i); if(press_button() > newlim) { move_out(i); } else currlist.push_back(i); } if(ct == tot * newlim) { uplim += (1<<e); } else { for(int z : currlist) move_out(z); } } return uplim; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...