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>
#include "insects.h"
using namespace std;
int min_cardinality(int n) {
vector <bool> vis (n);
int tp = 0;
for (int i = 0; i < n; i++){
move_inside(i);
if (press_button() == 2) {
move_outside(i);
}
else {
vis[i] = 1;
tp++;
}
}
if (tp * tp <= n) {
for (int i = 0; i < n; i++) if (vis[i]) move_outside(i);
vector <int> type(n, -1);
int l = 0;
int rs = 1e9;
for (int i = 0; i < n; i++){
if (type[i] != -1) continue;
int k = 1;
type[i] = l++;
move_inside(i);
for (int j = 0; j < n; j++){
if (i == j || type[j] != -1) continue;
move_inside(j);
// cout << i << " " << j << " " << press_button() << "\n";
if (press_button() == 2) type[j] = type[i], k++;
move_outside(j);
}
move_outside(i);
rs = min(rs, k);
}
return rs;
}
for (int i = 2; i <= n + 1; i++){
int d = 0;
for (int j = 0; j < n; j++){
if (vis[j]) continue;
move_inside(j);
if (press_button() == i + 1) {
move_outside(j);
}
else {
vis[j] = 1;
d++;
}
}
if (d != tp) return i-1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |