| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1286279 | lopkus | 드문 곤충 (IOI22_insects) | C++20 | 1 ms | 400 KiB |
#include <bits/stdc++.h>
#include "insects.h"
std::vector<int> added;
void add(int i) {
added.push_back(i);
move_inside(i);
}
void del(int i) {
move_outside(i);
}
int get() {
return press_button();
}
int del_all() {
for(auto x : added) {
del(x);
}
added.clear();
}
int min_cardinality(int n) {
int s = std::sqrt(n);
int cnt = 0;
std::vector<int> vec;
for(int i = 0; i < n; i++) {
add(i);
if(get() == 1) {
cnt += 1;
vec.push_back(i);
// first occurent
}
else {
del(i);
}
}
return 0;
del_all();
if(cnt <= s) {
int ans = n + 1;
for(auto x : vec) {
add(x);
int occ = 1;
for(int i = 0; i < n; i++) {
if(i == x) {
continue;
}
add(i);
if(get() == occ + 1) {
occ += 1;
}
else {
del(i);
}
}
ans = std::min(ans, occ);
del_all();
}
return ans;
}
else {
std::vector<int> was(n);
for(int occ = 1; occ <= s; occ++) {
int all = 0;
for(int i = 0; i < n; i++) {
if(was[i]) {
continue;
}
add(i);
if(get() == occ) {
all += 1;
was[i] = 1;
}
else {
del(i);
}
}
if(cnt != all) {
return occ - 1;
}
}
}
}
컴파일 시 표준 에러 (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... | ||||
