Submission #1077048

#TimeUsernameProblemLanguageResultExecution timeMemory
1077048mariaclaraRarest Insects (IOI22_insects)C++17
70.01 / 100
88 ms680 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); int colors = 0; srand(381723); for(int i = 0; i < N; i++) { move_inside(i); in[i] = 1; if(press_button() == 2) move_outside(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)/3, qtd = 0; if(r == 1) return 1; for(int i = 0; i < N; i++) { if(in[i]) {qtd++; continue;} in[i] = 1; move_inside(i); if(press_button() > mid) move_outside(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(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...