# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667041 | mychecksedad | 드문 곤충 (IOI22_insects) | C++17 | 1 ms | 336 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 <bits/stdc++.h>
using namespace std;
#define pb push_back
void move_inside(int i);
void move_outside(int i);
int press_button();
int min_cardinality(int n){
set<int> v;
for(int i = 0; i < n; ++i){
v.insert(i);
move_inside(i);
}
int ans = n;
while(1){
int k = press_button(), m = sqrt(v.size());
vector<bool> in(n, 1);
if(k == v.size() || k == 1){
return k;
}else if(k >= m){
int index = 0;
for(int i: v){
move_outside(i);
in[i] = 0;
int k1 = press_button();
if(k1 != k){
index = i;
break;
}
}
for(int x: v) if(in[x]) move_outside(x), in[x] = 0;
move_inside(index);
in[index] = 1;
for(int i: v){
if(i != index){
move_inside(i);
int k1 = press_button();
if(k1 > 1){
v.erase(i);
}
move_outside(i);
}
}
v.erase(index);
}else{
for(int i: v){
in[i] = 0;
move_outside(i);
}
int group_num = 0;
for(int i: v){
move_inside(i);
int k1 = press_button();
in[i] = 1;
if(k1 > 1){
move_outside(i);
in[i] = 0;
}else group_num++;
}
vector<int> removed;
for(int i: v){
if(in[i]) continue;
move_inside(i);
int k1 = press_button();
if(k1 == k){
removed.pb(i);
move_outside(i);
}else in[i] = 1;
}
if(removed.size() == group_num){
return k;
}
for(int i: removed) v.erase(i);
}
for(int x: v) if(!in[x]) move_inside(x);
}
return ans;
}
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... |