QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793832#4565. Rarest Insects_8_8_0 85ms4052kbC++201.6kb2024-11-30 02:20:542024-11-30 02:20:55

Judging History

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

  • [2024-11-30 02:20:55]
  • 评测
  • 测评结果:0
  • 用时:85ms
  • 内存:4052kb
  • [2024-11-30 02:20:54]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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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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 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.