Submission #1185288

#TimeUsernameProblemLanguageResultExecution timeMemory
1185288thelegendary08Rarest Insects (IOI22_insects)C++17
0 / 100
2 ms408 KiB
#include "insects.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i = 0; i<n; i++) #define vi vector<int> #define vb vector<bool> #define pb push_back using namespace std; int min_cardinality(int N) { vi perm; f0r(i, N)perm.pb(i); random_shuffle(perm.begin(), perm.end()); vb in(N); vb notin(N); f0r(i, N){ move_inside(perm[i]); in[i] = 1; int x = press_button(); if(x > 1){ move_outside(perm[i]); in[i] = 0; } } int d = 0; f0r(i, N){ if(in[i])d++; } int lo = 1; int hi = N/d+1; while(lo < hi){ int mid = lo + (hi - lo + 1) / 2; vi lst; f0r(i, N){ if(!in[i] && !notin[i]){ move_inside(perm[i]); in[i] = 1; int x = press_button(); if(x > mid){ move_outside(perm[i]); in[i] = 0; } else{ lst.pb(perm[i]); } } } int cnt = 0; f0r(i, N){ if(in[i])cnt++; } if(cnt == d * mid){ lo = mid; } else{ hi = mid - 1; f0r(i, N){ if(!in[i]){ notin[i] = 1; } } for(auto u : lst){ move_outside(u); in[u] = 0; } } } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...