#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> cur_v, perm;
int qry(vector<int> v) {
sort(v.begin(), v.end());
vector<int> chng;
set_symmetric_difference(v.begin(), v.end(), cur_v.begin(), cur_v.end(), back_inserter(chng));
for (int i : chng) {
if (binary_search(v.begin(), v.end(), i)) {
move_inside(perm[i]);
} else {
move_outside(perm[i]);
}
}
cur_v = v;
return press_button();
}
mt19937 rng(998244353);
int min_cardinality(int N) {
perm.resize(N);
iota(perm.begin(), perm.end(), 0);
shuffle(perm.begin(), perm.end(), rng);
vector<int> rep, cnt(N, 0);
for (int i = 0; i < N; i++) {
int lnk = -1;
{
shuffle(rep.begin(), rep.end(), rng);
int lo = 0, hi = (int)rep.size() - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
vector<int> cur = {i};
for (int j = 0; j <= mid; j++) {
cur.pb(rep[j]);
}
if (qry(cur) > 1) {
lnk = rep[mid];
hi = mid - 1;
} else {
lo = mid + 1;
}
}
}
if (lnk == -1) {
cnt[i]++;
} else {
cnt[lnk]++;
rep.erase(find(rep.begin(), rep.end(), lnk));
}
rep.pb(i);
}
int ret = N;
for (int i = 0; i < N; i++) {
if (cnt[i]) {
ret = min(ret, cnt[i]);
}
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Incorrect |
1 ms |
208 KB |
Wrong answer. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Incorrect |
1 ms |
208 KB |
Wrong answer. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Incorrect |
0 ms |
208 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |