QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430032#4565. Rarest Insectsjames1BadCreeper#0 8ms4184kbC++171.6kb2024-06-03 11:45:042024-06-03 11:45:05

Judging History

你现在查看的是最新测评结果

  • [2024-06-03 11:45:05]
  • 评测
  • 测评结果:0
  • 用时:8ms
  • 内存:4184kb
  • [2024-06-03 11:45:04]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h>
using namespace std; 
const int N = 2e3 + 5; 

// 最多问 3n 次询问
int n, m, k, id[N]; 
bool in[N]; 
mt19937 Rand(time(0)); 

void Move_inside(int x) { move_inside(id[x] - 1); }
void Move_outside(int x) { move_outside(id[x] - 1); }
bool check(int x) { // 最罕见的昆虫是否能 >= x
    int cnt = n; 
    for (int i = 1; i <= n; ++i) {
        Move_inside(i); in[i] = 1; 
        if (press_button() > x) {
            Move_outside(i), in[i] = 0, --cnt; 
            if (cnt < k * x) {
                for (int i = 1; i <= n; ++i)
                    if (in[i]) Move_outside(i), in[i] = 0; 
                return 0; 
            }
        }
    }
    for (int i = 1; i <= n; ++i)
        if (in[i]) Move_outside(i); 
    return cnt == k * x; 
}
int min_cardinality(int N) {
    n = N; 
    k = n; 
    for (int i = 1; i <= n; ++i) id[i] = i; 
    shuffle(id + 1, id + n + 1, Rand);  
    for (int i = 1; i <= n; ++i) {
        Move_inside(i), in[i] = 1; 
        if (press_button() > 1) Move_outside(i), in[i] = 0, --k; 
    }
    for (int i = 1; i <= n; ++i)
        if (in[i]) Move_outside(i); 
    if (k == 1) return 1; 
    int L = 1, R = n / k + 1; 
    while (L + 1 != R) {
        int mid = L + R >> 1; 
        if (check(mid)) L = mid; 
        else R = mid; 
    }
    return L; 
}

// 我们可以知道的信息:

// n 次代价知道昆虫种类数 k
// n 次代价知道最常见的昆虫基数

// 那么最罕见的昆虫的基数至多是 n / k
// 直接扫,

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: 3956kb

input:

6
1
1
2
2
2
1
1
1
2
2
3

output:

8
0 0
8
2
8
0 2
8
2
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
0 1
8
2
8
1 0
8
1 2
8
1 1
8
0 0
8
2
8
0 2
8
2
8
0 5
8
2
8
0 3
8
2
8
0 4
8
2
8
1 4
8
1 0
8
1 2
8
1 5
8
1 3
8
1 1
8
3 1

result:

ok 

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3956kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
1 0
8
3 1

result:

wrong answer Wrong answer.

Subtask #2:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 8ms
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 533
8
2
8
0 798
8
2
8
1 798
8
0 927
8
2
8
1 927
8
0 442
8
2
8
1 442
8
0 458
8
2
8
1 458
8
0 100
8
2
8
1 100
8
0 263
8
2
8
1 263
8
0 42
8
2
8
1 42
8
0 767
8
2
8
1 767
8
0 540
8
2
8
1 540
8
0 235
8
2
8
1 235
8
0 112
8
2
8
1 112
8
0 344
8
2
8
1 344
8
0 908
8
2
8
1 908
8
0 808
8
2
8
1 808
8
0 211
8
...

result:

wrong answer Wrong answer.

Subtask #3:

score: 0
Wrong Answer

Test #43:

score: 0
Wrong Answer
time: 1ms
memory: 4184kb

input:

2
1
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
1 0
8
3 1

result:

wrong answer Wrong answer.