QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#430102 | #4565. Rarest Insects | james1BadCreeper | 0 | 1ms | 3892kb | C++17 | 1.5kb | 2024-06-03 14:29:27 | 2024-06-03 14:29:28 |
answer
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
// 最多问 3n 次询问
int n, m, k, always_no[N];
vector<int> arr;
bool in[N];
mt19937 Rand(time(0));
inline void Move_inside(int x) { move_inside(x - 1); }
inline void Move_outside(int x) { move_outside(x - 1); }
bool check(int x) { // 最罕见的昆虫是否能 >= x
int cnt = n;
vector<int> newarr;
shuffle(arr.begin(), arr.end(), Rand);
for (int i : arr) {
Move_inside(i); in[i] = 1;
if (press_button() > x) {
Move_outside(i); in[i] = 0; --cnt; newarr.emplace_back(i);
if (cnt < k * x) {
for (int i : arr)
if (in[i]) Move_outside(i), in[i] = 0;
return 0;
}
}
}
if (cnt == k * x) {
arr = newarr;
// for (int i : newarr) in[i] = 0;
return 1;
}
for (int i : arr)
if (in[i]) Move_outside(i), in[i] = 0;
return 0;
}
int min_cardinality(int N) {
n = N;
k = n;
for (int i = 1; i <= n; ++i) always_no[i] = 0;
for (int i = 1; i <= n; ++i) {
Move_inside(i);
if (press_button() > 1) Move_outside(i), --k, arr.emplace_back(i);
}
// 最罕见的出现次数是 1,当且仅当什么时候?
int L = 1, R = n / k, ans = 1; // [2, n / k]
while (L < R) {
int mid = L + R >> 1;
if (check(mid)) L = mid + 1, ans = mid;
else R = mid;
}
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 3892kb
input:
6 1 1 1 2 2 2 2 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 0 2 8 2 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 5 8 2 8 1 5 8 0 5 8 2 8 1 5 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 3 1
result:
ok
Test #2:
score: -10
Wrong Answer
time: 0ms
memory: 3828kb
input:
2 1 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 3 1
result:
wrong answer Wrong answer.
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
input:
1000 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 2 8 2 8 1 2 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 5 8 2 8 1 5 8 0 6 8 2 8 1 6 8 0 7 8 2 8 1 7 8 0 8 8 2 8 1 8 8 0 9 8 2 8 1 9 8 0 10 8 2 8 1 10 8 0 11 8 2 8 1 11 8 0 12 8 2 8 1 12 8 0 13 8 2 8 1 13 8 0 14 8 2 8 1 14 8 0 15 8 2 8 1 15 8 0 16 8 2 8 1 16 8 0 17 8 2 8 1 17 8 ...
result:
wrong answer Wrong answer.
Subtask #3:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
2 1 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 3 1
result:
wrong answer Wrong answer.