QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#518271 | #4565. Rarest Insects | Dan4Life# | 0 | 145ms | 97936kb | C++23 | 1.4kb | 2024-08-13 19:02:21 | 2024-08-13 19:02:21 |
Judging History
answer
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
using vi = vector<int>;
using ll = long long;
using ar2 = array<ll,2>;
using ar3 = array<ll,3>;
const int mxN = (int)2e3+10;
int n, cnt[mxN];
vi v, others;
set<int> S;
map<set<int>,int> M;
void move_in(int i){
if(S.count(i)) return;
S.insert(i); move_inside(i);
}
void move_out(int i){
if(!S.count(i)) return;
S.erase(i); move_outside(i);
}
int press(){
if(M.count(S)) return M[S];
return M[S] = press_button();
}
void dnc(int l, int r, vi query){
if(l>r) return;
if(l==r or !sz(query)){
cnt[v[l]]+=sz(query);
return;
}
int mid = (l+r)/2;
vi qL, qR; qL.clear(), qR.clear();
for(int i = l; i <= mid; i++) move_in(v[i]);
for(auto i : query){
move_in(i);
if(press()==2) qL.pb(i);
else qR.pb(i);
move_out(i);
}
for(int i = mid+1; i <= r; i++) move_out(v[i]);
dnc(l,mid,qL);
for(int i = l; i <= mid; i++) move_out(v[i]);
dnc(mid+1,r,qR);
}
int min_cardinality(int N) {
n = N; int ans = n;
vector<int> xd(n,0); iota(all(xd),0);
random_shuffle(all(xd));
for(int i = 0; i < n; i++){
move_in(xd[i]); v.pb(xd[i]);
if(press()==2)
move_out(xd[i]), v.pop_back(), others.pb(xd[i]);
}
for(auto u : v) move_out(u);
for(auto u : v) cnt[u]++;
dnc(0,sz(v)-1,others);
for(auto u : v) ans = min(ans, cnt[u]);
return ans;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3824kb
input:
6 1 1 1 2 2 2 2 2 2
output:
8 0 4 8 2 8 0 3 8 2 8 0 1 8 2 8 0 2 8 2 8 1 2 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 1 4 8 1 3 8 1 1 8 0 4 8 0 3 8 0 2 8 2 8 1 2 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 0 2 8 1 2 8 0 0 8 1 0 8 0 5 8 1 5 8 1 3 8 1 4 8 3 1
result:
ok
Test #2:
score: 10
Accepted
time: 1ms
memory: 3832kb
input:
2 1 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 1 0 8 3 2
result:
ok
Test #3:
score: 10
Accepted
time: 0ms
memory: 3892kb
input:
2 1 1
output:
8 0 0 8 2 8 0 1 8 2 8 1 0 8 1 1 8 3 1
result:
ok
Test #4:
score: 10
Accepted
time: 0ms
memory: 4088kb
input:
3 1 1 2 1
output:
8 0 0 8 2 8 0 2 8 2 8 0 1 8 2 8 1 1 8 1 0 8 1 2 8 0 0 8 0 1 8 2 8 1 1 8 1 0 8 3 1
result:
ok
Test #5:
score: 10
Accepted
time: 1ms
memory: 3828kb
input:
5 1 2 1 2 2 1 2
output:
8 0 4 8 2 8 0 3 8 2 8 1 3 8 0 1 8 2 8 0 2 8 2 8 1 2 8 0 0 8 2 8 1 0 8 1 4 8 1 1 8 0 4 8 0 3 8 1 3 8 0 2 8 2 8 1 2 8 0 0 8 2 8 1 0 8 1 4 8 3 2
result:
ok
Test #6:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
8 1 2 1 1 2 2 2 2 2 1 2 2 2
output:
8 0 4 8 2 8 0 3 8 2 8 1 3 8 0 7 8 2 8 0 6 8 2 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 0 2 8 2 8 1 2 8 0 1 8 2 8 1 1 8 1 4 8 1 7 8 1 6 8 0 4 8 0 7 8 0 3 8 2 8 1 3 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 0 2 8 2 8 1 2 8 0 1 8 2 8 1 1 8 0 3 8 1 3 8 0 5 8 1 5 8 0 2 8 1 2 8 0 1 8 1 1 8 1 7 8 1 4 8 3 1
result:
ok
Test #7:
score: 10
Accepted
time: 0ms
memory: 3876kb
input:
199 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 110 8 2 8 0 51 8 2 8 1 51 8 0 11 8 2 8 1 11 8 0 69 8 2 8 1 69 8 0 119 8 2 8 1 119 8 0 142 8 2 8 1 142 8 0 17 8 2 8 1 17 8 0 109 8 2 8 1 109 8 0 164 8 2 8 1 164 8 0 101 8 2 8 1 101 8 0 115 8 2 8 1 115 8 0 39 8 2 8 1 39 8 0 108 8 2 8 1 108 8 0 2 8 2 8 1 2 8 0 75 8 2 8 1 75 8 0 56 8 2 8 1 56 8 0 59...
result:
ok
Test #8:
score: 10
Accepted
time: 1ms
memory: 5064kb
input:
200 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
8 0 110 8 2 8 0 51 8 2 8 0 11 8 2 8 0 69 8 2 8 0 119 8 2 8 0 142 8 2 8 0 17 8 2 8 0 109 8 2 8 0 164 8 2 8 0 101 8 2 8 0 115 8 2 8 0 39 8 2 8 0 108 8 2 8 0 2 8 2 8 0 75 8 2 8 0 56 8 2 8 0 59 8 2 8 0 166 8 2 8 0 153 8 2 8 0 116 8 2 8 0 143 8 2 8 0 86 8 2 8 0 57 8 2 8 0 133 8 2 8 0 169 8 2 8 0 192 8 2 ...
result:
ok
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 4236kb
input:
200 1 1 1 1 2 1 1 1 2 2 2 1 1 1 2 2 1 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 110 8 2 8 0 51 8 2 8 0 11 8 2 8 0 69 8 2 8 0 119 8 2 8 1 119 8 0 142 8 2 8 0 17 8 2 8 0 109 8 2 8 0 164 8 2 8 1 164 8 0 101 8 2 8 1 101 8 0 115 8 2 8 1 115 8 0 39 8 2 8 0 108 8 2 8 0 2 8 2 8 0 75 8 2 8 1 75 8 0 56 8 2 8 1 56 8 0 59 8 2 8 0 166 8 2 8 0 153 8 2 8 0 116 8 2 8 0 143 8 2 8 1 143 8 0 ...
result:
wrong answer Wrong answer.
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 15
Accepted
time: 0ms
memory: 4064kb
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 110 8 2 8 0 290 8 2 8 1 290 8 0 701 8 2 8 1 701 8 0 69 8 2 8 1 69 8 0 560 8 2 8 1 560 8 0 468 8 2 8 1 468 8 0 706 8 2 8 1 706 8 0 896 8 2 8 1 896 8 0 164 8 2 8 1 164 8 0 926 8 2 8 1 926 8 0 795 8 2 8 1 795 8 0 322 8 2 8 1 322 8 0 361 8 2 8 1 361 8 0 2 8 2 8 1 2 8 0 567 8 2 8 1 567 8 0 792 8 2 8 ...
result:
ok
Test #25:
score: 15
Accepted
time: 30ms
memory: 27484kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
8 0 110 8 2 8 0 290 8 2 8 0 701 8 2 8 0 69 8 2 8 0 560 8 2 8 0 468 8 2 8 0 706 8 2 8 0 896 8 2 8 0 164 8 2 8 0 926 8 2 8 0 795 8 2 8 0 322 8 2 8 0 361 8 2 8 0 2 8 2 8 0 567 8 2 8 0 792 8 2 8 0 602 8 2 8 0 929 8 2 8 0 643 8 2 8 0 720 8 2 8 0 589 8 2 8 0 826 8 2 8 0 420 8 2 8 0 578 8 2 8 0 363 8 2 8 0...
result:
ok
Test #26:
score: 0
Wrong Answer
time: 7ms
memory: 7564kb
input:
999 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 1 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 2 2 2 1 2 1 2 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 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 ...
output:
8 0 110 8 2 8 0 290 8 2 8 0 701 8 2 8 1 701 8 0 69 8 2 8 0 560 8 2 8 0 468 8 2 8 0 706 8 2 8 0 896 8 2 8 0 164 8 2 8 0 926 8 2 8 1 926 8 0 795 8 2 8 0 322 8 2 8 0 361 8 2 8 0 2 8 2 8 0 567 8 2 8 0 792 8 2 8 0 602 8 2 8 1 602 8 0 929 8 2 8 0 643 8 2 8 0 720 8 2 8 0 589 8 2 8 1 589 8 0 826 8 2 8 0 420...
result:
wrong answer Wrong answer.
Subtask #3:
score: 0
Wrong Answer
Test #43:
score: 75
Accepted
time: 0ms
memory: 3824kb
input:
2 1 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 1 0 8 3 2
result:
ok
Test #44:
score: 75
Accepted
time: 0ms
memory: 3800kb
input:
2 1 1
output:
8 0 0 8 2 8 0 1 8 2 8 1 0 8 1 1 8 3 1
result:
ok
Test #45:
score: 75
Accepted
time: 1ms
memory: 4128kb
input:
3 1 1 2 1
output:
8 0 0 8 2 8 0 2 8 2 8 0 1 8 2 8 1 1 8 1 0 8 1 2 8 0 0 8 0 1 8 2 8 1 1 8 1 0 8 3 1
result:
ok
Test #46:
score: 75
Accepted
time: 0ms
memory: 3836kb
input:
6 1 2 2 1 2 2 2 2
output:
8 0 4 8 2 8 0 3 8 2 8 1 3 8 0 1 8 2 8 1 1 8 0 2 8 2 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 1 4 8 1 2 8 0 4 8 0 3 8 1 3 8 0 1 8 1 1 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 1 4 8 3 1
result:
ok
Test #47:
score: 75
Accepted
time: 0ms
memory: 3836kb
input:
10 1 1 2 2 2 2 2 2 2 2 1 2 2 2 1 1 2 2
output:
8 0 4 8 2 8 0 3 8 2 8 0 7 8 2 8 1 7 8 0 8 8 2 8 1 8 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 0 2 8 2 8 1 2 8 0 1 8 2 8 1 1 8 0 6 8 2 8 1 6 8 0 9 8 2 8 1 9 8 1 4 8 1 3 8 0 4 8 0 7 8 2 8 1 7 8 0 8 8 2 8 1 8 8 0 0 8 2 8 1 0 8 0 5 8 2 8 1 5 8 0 2 8 2 8 1 2 8 0 1 8 2 8 1 1 8 0 6 8 2 8 1 6 8 0 9 8 2 8 1 9 8 1 4 ...
result:
ok
Test #48:
score: 75
Accepted
time: 0ms
memory: 4248kb
input:
2000 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 1204 8 2 8 0 1190 8 2 8 1 1190 8 0 701 8 2 8 1 701 8 0 1768 8 2 8 1 1768 8 0 1059 8 2 8 1 1059 8 0 468 8 2 8 1 468 8 0 706 8 2 8 1 706 8 0 1131 8 2 8 1 1131 8 0 164 8 2 8 1 164 8 0 1195 8 2 8 1 1195 8 0 1213 8 2 8 1 1213 8 0 1029 8 2 8 1 1029 8 0 361 8 2 8 1 361 8 0 1649 8 2 8 1 1649 8 0 1735 8 ...
result:
ok
Test #49:
score: 75
Accepted
time: 145ms
memory: 97936kb
input:
2000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
8 0 1204 8 2 8 0 1190 8 2 8 0 701 8 2 8 0 1768 8 2 8 0 1059 8 2 8 0 468 8 2 8 0 706 8 2 8 0 1131 8 2 8 0 164 8 2 8 0 1195 8 2 8 0 1213 8 2 8 0 1029 8 2 8 0 361 8 2 8 0 1649 8 2 8 0 1735 8 2 8 0 1979 8 2 8 0 1416 8 2 8 0 1194 8 2 8 0 643 8 2 8 0 720 8 2 8 0 1575 8 2 8 0 1556 8 2 8 0 420 8 2 8 0 1701 ...
result:
ok
Test #50:
score: 0
Wrong Answer
time: 48ms
memory: 13244kb
input:
2000 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 1 1 1 2 2 1 2 2 2 2 2 2 2 2 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 1 1 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2...
output:
8 0 1204 8 2 8 0 1190 8 2 8 0 701 8 2 8 0 1768 8 2 8 0 1059 8 2 8 1 1059 8 0 468 8 2 8 0 706 8 2 8 0 1131 8 2 8 0 164 8 2 8 0 1195 8 2 8 1 1195 8 0 1213 8 2 8 0 1029 8 2 8 1 1029 8 0 361 8 2 8 0 1649 8 2 8 0 1735 8 2 8 0 1979 8 2 8 1 1979 8 0 1416 8 2 8 0 1194 8 2 8 0 643 8 2 8 0 720 8 2 8 0 1575 8 ...
result:
wrong answer Wrong answer.