Submission #1077032

#TimeUsernameProblemLanguageResultExecution timeMemory
1077032mariaclaraRarest Insects (IOI22_insects)C++17
47.50 / 100
145 ms848 KiB
#include "insects.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second int min_cardinality(int N) { vector<int> in(N), M; int colors = 0; for(int i = 0; i < N; i++) { move_inside(i); in[i] = 1; M.pb(i); if(press_button() == 2) move_outside(i), M.pop_back(), in[i] = 0; else colors++; } int l = 1, r = N/colors; while(l <= r) { int mid = (l+r)/2; for(int i = 0; i < N; i++) { if(in[i]) continue; in[i] = 1; move_inside(i); M.pb(i); if(press_button() > mid) move_outside(i), in[i] = 0, M.pop_back(); } if(sz(M) == colors*mid) l = mid+1; else r = mid-1; for(int i = 0; i < N; i++) if(in[i]) move_outside(i), in[i] = 0, M.pop_back(); } return l-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...