QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#520725 | #4565. Rarest Insects | kimmoqt | 0 | 1ms | 3984kb | C++20 | 3.6kb | 2024-08-15 15:10:44 | 2024-08-15 15:10:44 |
answer
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
const int MX=2005;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int cnt[MX], L[MX], R[MX];
int min_cardinality(int N) {
vector<bool> vis(N);
vector<int> pos;
for(int i=0;i<N;i++) {
if(vis[i]) continue;
move_inside(i);
if(press_button()==2) {
move_outside(i);
} else {
vis[i]=true;
pos.push_back(i);
}
}
if(pos.size()>=256) {
int p=pos.size(),res=1;
while(true) {
for(auto x:pos) {
move_outside(x);
}
pos.clear();
for(int i=0;i<N;i++) {
if(vis[i]) continue;
move_inside(i);
if(press_button()==2) {
move_outside(i);
} else {
vis[i]=true;
pos.push_back(i);
}
}
if(pos.size()!=p) break;
res++;
}
return res;
} else {
for(auto x:pos) {
move_outside(x);
}
for(int i=0;i<N;i++) {
L[i]=0;
R[i]=pos.size()-1;
}
for(int it=0;it<8;it++) {
vector<array<int,3>> seg;
for(int i=0;i<N;i++) {
if(vis[i]) continue;
int m=(L[i]+R[i])/2;
if(R[i]>L[i]) {
seg.push_back({L[i],m,i});
}
}
sort(seg.begin(),seg.end());
for(int i=0;i<seg.size();i++) {
int j=i;
while(j+1<seg.size() && seg[j+1][0]==seg[j][0]) j++;
for(int k=seg[i][0];k<=seg[i][1];k++) {
move_inside(pos[k]);
}
for(int k=i;k<=j;k++) {
move_inside(seg[k][2]);
if(press_button()==2) {
R[seg[k][2]]=seg[k][1];
} else {
L[seg[k][2]]=seg[k][1]+1;
}
move_outside(seg[k][2]);
}
for(int k=seg[i][0];k<=seg[i][1];k++) {
move_outside(pos[k]);
}
i=j;
}
}
for(int i=0;i<N;i++) {
cnt[L[i]]++;
}
int res=N;
for(int i=0;i<pos.size();i++) {
res=min(res,cnt[i]);
}
return res+1;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3984kb
input:
6 1 1 1 2 2 2 2 1 1 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 1 0 8 1 1 8 1 2 8 0 0 8 0 1 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 1 0 8 1 1 8 0 0 8 0 3 8 2 8 1 3 8 1 0 8 3 1
result:
ok
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 3984kb
input:
2 1 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 1 0 8 3 3
result:
wrong answer Wrong answer.
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 0ms
memory: 3920kb
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: 0ms
memory: 3840kb
input:
2 1 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 1 0 8 3 3
result:
wrong answer Wrong answer.