#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;
bool gasit = false;
vector<ii> cauta(vi Cul, vi V) {
vector<ii> Re;
if(gasit || V.empty()) return Re;
if(Cul.size() == 1) {
if(V.size() == 1) {
gasit = true;
return vector<ii>();
}
for(auto it : V) Re.push_back({it, Cul[0]});
return Re;
}
vi C1, C2;
for(int i = 0; i < int(Cul.size()) / 2; ++i) {
C1.push_back(Cul[i]);
}
for(int i = int(Cul.size()) / 2; i < int(Cul.size()); ++i) {
C2.push_back(Cul[i]);
}
for(auto it : C1) {
move_inside(it);
}
vi V1, V2;
for(auto it : V) {
move_inside(it);
if(press_button() == 2) V1.push_back(it);
else V2.push_back(it);
move_outside(it);
}
for(auto it : C1) {
move_outside(it);
}
auto Re1 = cauta(C1, V1), Re2 = cauta(C2, V2);
for(auto it : Re1) Re.push_back(it);
for(auto it : Re2) Re.push_back(it);
return Re;
}
int min_cardinality(int n) {
vi Cul, Rest;
for(int i = 0; i < n; ++i) {
move_inside(i);
if(press_button() == 1) {
Cul.push_back(i);
} else {
move_outside(i);
Rest.push_back(i);
}
}
for(auto it : Cul) move_outside(it);
if(Cul.size() > Rest.size()) return 1;
auto Per = cauta(Cul, Rest);
if(gasit) return 1;
map<int, int> Fr;
for(auto it : Cul) ++Fr[it];
for(auto [p, cul] : Per) ++Fr[cul];
int mi = n;
for(auto [cul, fr] : Fr) mi = min(mi, fr);
return mi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong answer. |
3 |
Halted |
0 ms |
0 KB |
- |