# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736472 | puppy | Rarest Insects (IOI22_insects) | C++17 | 70 ms | 428 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 <vector>
#include <set>
#include <iostream>
using namespace std;
int dc[2005];
//1: 계속 넣을 것, 2: 계속 뺄 것
int min_cardinality(int N) {
set<int> st;
for (int i = 0; i < N; i++) {
move_inside(i);
st.insert(i);
if (press_button() > 1) {
move_outside(i);
st.erase(i);
}
else {
dc[i] = 1; //계속 넣고 있을 것
}
}
int S = st.size(); //총 종류 수
int l = 1, r = N / S;
while (l < r) {
int m = l + r + 1 >> 1;
//답이 m 미만인지 체크
for (int i = 0; i < N; i++) {
if (dc[i] == 1 || dc[i] == 2) continue;
move_inside(i);
st.insert(i);
if (press_button() > m) {
move_outside(i);
st.erase(i);
}
else {
dc[i] = 3; //2: 일단 넣고 있는 것
}
}
if (st.size() != m * S) {
r = m - 1;
//뺀 것들은 다시 안 넣을 것
for (int i = 0; i < N; i++) {
if (dc[i] == 0) dc[i] = 2;
else if (dc[i] == 3) dc[i] = 0;
}
}
else {
l = m;
for (int i = 0; i < N; i++) {
if (dc[i] == 3) dc[i] = 1;
}
}
for (int i = 0; i < N; i++) {
if (dc[i] != 1 && dc[i] != 2 && st.find(i) != st.end()) {
st.erase(i);
move_outside(i);
}
}
}
return l;
}
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... |