제출 #630992

#제출 시각아이디문제언어결과실행 시간메모리
630992blue드문 곤충 (IOI22_insects)C++17
47.50 / 100
243 ms560 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) { // cerr << "insert " << i << '\n'; if(ins[i]) return; ins[i] = 1; move_inside(i); ct++; } void move_out(int i) { // cerr << "erase " << i << '\n'; 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'; vi currlist; for(int i = 0; i < N; i++) currlist.push_back(i); int lo = 0, hi = N; while(lo != hi) { int mid = (lo+hi)/2 + 1; // cerr << lo << ' ' << hi << " : " << mid << '\n'; vi inlist, outlist; for(int i : currlist) { if(ins[i]) continue; move_in(i); if(press_button() > mid) { outlist.push_back(i); move_out(i); } else inlist.push_back(i); } // cerr << "ct = " << ct << '\n'; if(ct == mid * tot) { lo = mid; } else { hi = mid - 1; for(int f : inlist) move_out(f); } } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...