QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#398072 | #4565. Rarest Insects | hos_lyric | 0 | 12ms | 4108kb | C++14 | 912b | 2024-04-24 21:50:11 | 2024-04-24 21:50:12 |
Judging History
answer
#include "insects.h"
#include <vector>
using std::vector;
#define push move_inside
#define pop move_outside
#define get press_button
vector<int> us, vs, ws;
// us -> in: vs, out: ws
void go(int thr) {
vs.clear();
ws.clear();
for (const int u : us) {
push(u);
if (get() <= thr) {
vs.push_back(u);
} else {
pop(u);
ws.push_back(u);
}
}
}
int min_cardinality(int N) {
us.resize(N);
for (int u = 0; u < N; ++u) us[u] = u;
int lo = 1;
go(lo);
const int K = vs.size();
us.swap(ws);
int hi = N / K + 1;
go(hi);
us.swap(vs);
// keep inside: lo insects of each type
for (; lo + 1 < hi; ) {
const int mid = (lo + hi) / 2;
go(mid);
if ((int)vs.size() >= K * (mid - lo)) {
lo = mid;
us.swap(ws);
} else {
hi = mid;
us.swap(vs);
}
}
return lo;
}
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: 3800kb
input:
6 1 1 1 2 2 2 2 2 3 3 3 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 3 8 2 8 0 4 8 2 8 0 5 8 2 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 5 8 2 8 3 1
result:
ok
Test #2:
score: 10
Accepted
time: 1ms
memory: 3748kb
input:
2 1 2 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 1 8 2 8 0 1 8 2 8 3 2
result:
ok
Test #3:
score: 10
Accepted
time: 0ms
memory: 4108kb
input:
2 1 1
output:
8 0 0 8 2 8 0 1 8 2 8 3 1
result:
ok
Test #4:
score: 10
Accepted
time: 0ms
memory: 3792kb
input:
3 1 1 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 0 2 8 2 8 1 2 8 0 2 8 2 8 3 1
result:
ok
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 3744kb
input:
5 1 1 2 2 2 2 2 3 3 3 2
output:
8 0 0 8 2 8 0 1 8 2 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 2 8 2 8 0 3 8 2 8 0 4 8 2 8 0 2 8 2 8 1 2 8 0 3 8 2 8 1 3 8 0 4 8 2 8 3 1
result:
wrong answer Wrong answer.
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 15
Accepted
time: 12ms
memory: 3896kb
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:
ok
Test #25:
score: 15
Accepted
time: 5ms
memory: 3784kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 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 8 0 11 8 2 8 0 12 8 2 8 0 13 8 2 8 0 14 8 2 8 1 14 8 0 15 8 2 8 1 15 8 0 16 8 2 8 0 17 8 2 8 0 18 8 2 8 0 19 8 2 8 0 20 8 2 8 0 21 8 2 8 0 22 8 2 8 1 22 8 0 23 8 2 8 1 23 8 0 24 8 2 8...
result:
wrong answer Wrong answer.
Subtask #3:
score: 0
Wrong Answer
Test #43:
score: 75
Accepted
time: 1ms
memory: 3880kb
input:
2 1 2 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 8 0 1 8 2 8 0 1 8 2 8 3 2
result:
ok
Test #44:
score: 75
Accepted
time: 0ms
memory: 3744kb
input:
2 1 1
output:
8 0 0 8 2 8 0 1 8 2 8 3 1
result:
ok
Test #45:
score: 75
Accepted
time: 0ms
memory: 3804kb
input:
3 1 1 2 2
output:
8 0 0 8 2 8 0 1 8 2 8 0 2 8 2 8 1 2 8 0 2 8 2 8 3 1
result:
ok
Test #46:
score: 75
Accepted
time: 0ms
memory: 3884kb
input:
6 1 2 1 2 2 2 2 3 4 5 4 3 2
output:
8 0 0 8 2 8 0 1 8 2 8 1 1 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 1 8 2 8 0 3 8 2 8 0 4 8 2 8 0 5 8 2 8 1 5 8 0 1 8 2 8 1 1 8 0 3 8 2 8 1 3 8 0 4 8 2 8 3 1
result:
ok
Test #47:
score: 0
Wrong Answer
time: 1ms
memory: 4096kb
input:
10 1 1 2 2 2 2 2 2 2 2 2 3 3 3 4 4 5 6 6 6 6 5 4 3 3 3 3 3 2
output:
8 0 0 8 2 8 0 1 8 2 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 2 8 2 8 0 3 8 2 8 0 4 8 2 8 0 5 8 2 8 0 6 8 2 8 0 7 8 2 8 0 8 8 2 8 0 9 8 2 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 ...
result:
wrong answer Wrong answer.