제출 #800647

#제출 시각아이디문제언어결과실행 시간메모리
800647QwertyPi드문 곤충 (IOI22_insects)C++17
47.50 / 100
159 ms416 KiB
#include "insects.h" #include <bits/stdc++.h> using namespace std; bool in[2011]; int cnt = 0; void move_in(int i){ assert(!in[i]); in[i] = true; move_inside(i); cnt++; } void move_out(int i){ assert(in[i]); in[i] = false; move_outside(i); cnt--; } int min_cardinality(int N) { fill(in, in + N, 0); for(int i = 0; i < N; i++){ move_in(i); int c = press_button(); if(c >= 2) move_out(i); } int K = cnt; int L = 1, R = N / K; while(L != R){ int M = (L + R + 1) / 2; vector<int> added; for(int i = 0; i < N; i++){ if(!in[i]) move_in(i), added.push_back(i); int c = press_button(); if(c > M) move_out(i), added.pop_back(); } if(cnt == M * K){ L = M; }else{ for(auto i : added){ move_out(i); } R = M - 1; } } return L; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...