QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#793832 | #4565. Rarest Insects | _8_8_ | 0 | 85ms | 4052kb | C++20 | 1.6kb | 2024-11-30 02:20:54 | 2024-11-30 02:20:55 |
Judging History
answer
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, u;
vector<int> p;
set<int> cur, lef;
void add(int i) {
cur.insert(i);
move_inside(i);
}
void del(int i) {
if(cur.count(i)) {
cur.erase(i);
move_outside(i);
}
}
int l , r;
bool check(int mid) {
if(mid * u > n) return false;
int col = 0;
int val = (int)lef.size() + (int)cur.size();
int it = 0;
for(int i : lef) {
add(i);
if(press_button() > mid) {
del(i);
col++;
}
it++;
}
if(col == val - mid * u) {
set<int> nv;
for(int i : lef) {
if(!cur.count(i)) {
nv.insert(i);
}
}
lef.swap(nv);
return 1;
}
// l = max(l, mid - (col - val + mid * u));
set<int> nv;
for(int i : lef) {
if(cur.count(i)) {
nv.insert(i);
}
del(i);
}
lef.swap(nv);
return false;
}
int min_cardinality(int NN) {
n = NN;
for(int i = 0; i < n; i++) {
lef.insert(i);
}
for(int i = 0; i < n; i++) {
add(i);
if(press_button() == 2) {
del(i);
} else {
lef.erase(i);
}
}
u = (int)cur.size();
l = 1, r = n + 1;
while(r - l > 1) {
int mid = (l * 2 + r) / 3;
if(check(mid)) {
l = mid;
} else {
r = mid;
}
}
return l;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 85ms
memory: 4052kb
input:
6 1 1 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 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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 Too many queries.
Subtask #3:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 54ms
memory: 3860kb
input:
2 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 2 ...
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 0 1 8 2 8 1 1 8 ...
result:
wrong answer Too many queries.