Submission #832975

#TimeUsernameProblemLanguageResultExecution timeMemory
832975MeGustaElArroz23Rarest Insects (IOI22_insects)C++17
47.50 / 100
159 ms516 KiB
#include "insects.h" using namespace std; #include<bits/stdc++.h> #define vi vector<int> #define vvi vector<vi> #define pii pair<int,int> #define vii vector<pii> #define fi first #define se second #define pb push_back #define vb vector<bool> int n; vb box; vb basic_box; int basic_box_size; void create_basic_box(){ basic_box=vb(n,0); for (int i=0;i<n;i++){ move_inside(i); box[i]=1; if (press_button()>1){ move_outside(i); box[i]=0; } } basic_box=box; basic_box_size=0; for (int x:basic_box) basic_box_size+=x; } void clear_box(){ for (int i=0;i<n;i++){ if (box[i] && (! basic_box[i])){ box[i]=0; move_outside(i); } } } int check_ans(int m){ for (int i=0;i<n;i++){ move_inside(i); box[i]=1; if (press_button()>m){ move_outside(i); box[i]=0; } } int count=0; for (int x:box) count+=x; clear_box(); if (count==m*basic_box_size) return 1; else return 0; } int min_cardinality(int N) { n=N; box=vb(n,0); create_basic_box(); clear_box(); int l=1; int r=n/basic_box_size+1; while (l!=r-1){ int m=(l+r)/2; if (check_ans(m)) l=m; else r=m; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...