# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631000 | garam1732 | Rarest Insects (IOI22_insects) | C++17 | 140 ms | 568 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "insects.h"
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <algorithm>
#define ff first
#define ss second
using namespace std;
typedef pair<int, int> pi;
//vector<int> ans;
//stack<pi> S, v;
vector<int> v, w;
set<int> s;
int min_cardinality(int N) {
int num = 0;
for(int i = 0; i < N; i++) {
move_inside(i);
num++;
if(press_button() > 1) {
move_outside(i);
num--;
s.insert(i);
}
}
int sum = num;
int lb = 1, ub = N, mid;
while(lb < ub) {
mid = (lb*3+ub+3)/4;
for(int i : s) {
move_inside(i);
if(press_button() > mid) {
move_outside(i);
v.push_back(i);
}
else w.push_back(i);
}
if(w.size()+sum == mid*num) {
lb = mid;
for(int t : w) s.erase(t);
sum += w.size();
}
else {
ub = mid-1;
for(int t : v) s.erase(t);
for(int t : w) move_outside(t);
}
v.clear();
w.clear();
}
return lb;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |