Submission #1077057

#TimeUsernameProblemLanguageResultExecution timeMemory
1077057mariaclaraRarest Insects (IOI22_insects)C++17
70.09 / 100
102 ms676 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 rand(int a, int b) { return rand()%(b-a+1) + a; } int min_cardinality(int N) { vector<int> in(N), ord(N); int colors = 0; srand(381723); for(int i = 0; i < N; i++) ord[i] = i; random_shuffle(all(ord)); for(int i = 0; i < N; i++) { move_inside(ord[i]); in[i] = 1; if(press_button() == 2) move_outside(ord[i]), in[i] = 0; else colors++; } if(colors == 1) return N; int l = 1, r = N/colors; while(l <= r) { int mid = l + (r-l+1)/5, qtd = 0; if(r == 1) return 1; for(int i = 0; i < N; i++) { if(in[i]) {qtd++; continue;} in[i] = 1; move_inside(ord[i]); if(press_button() > mid) move_outside(ord[i]), in[i] = 0; else qtd++; } if(qtd == colors*mid) l = mid+1; else { r = mid-1; for(int i = 0; i < N; i++) if(in[i]) move_outside(ord[i]), in[i] = 0; } } return l-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...