답안 #1074621

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074621 2024-08-25T11:27:44 Z Nicolaikrob 드문 곤충 (IOI22_insects) C++17
99.89 / 100
49 ms 956 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int n, tc, il, rc = 0;
set<int> M, IU;
vi IS;

void mi(int i) {
    move_inside(IS[i]);
    M.insert(i);
}

void mo(int i) {
    move_outside(IS[i]);
    M.erase(i);
}

int pb() {
    return press_button()+rc;
}

void rm(bool t) {
    if(t) {
        for(auto x : M) {
            IU.erase(x);
            move_outside(IS[x]);
        }
        il -= M.size();
        rc += M.size()/tc;
        M.clear();
    }
    else {
        IU = M;
        il = M.size();
        for(auto x : M)
            move_outside(IS[x]);
        M.clear();
    }
}

bool tjek(int g) {
    for(auto i : IU) {
        mi(i);
        if(pb() > g) mo(i);
    }
    bool s = (int(M.size())+rc*tc == tc*g);
    rm(s);
    return s;
}

int min_cardinality(int N) {
    il = n = N;
    IS.resize(n);
    for(int i = 0; i < n; i++)
        IS[i] = i;
    srand(time(NULL));
    random_shuffle(IS.begin(), IS.end());
    mi(0);
    for(int i = 1; i < n; i++) {
        mi(i);
        if(pb() > 1) mo(i);
    }
    tc = M.size();
    for(int i = 0; i < n; i++)
        IU.insert(i);
    rm(1);
    int l = 1, u = n/tc;
    while(l < u) {
        int g = (l+u+1)/2;
        if(tjek(g)) l = g;
        else u = g-1;
    }
    return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 424 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 436 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 424 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 4 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 2 ms 436 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 14 ms 488 KB Output is correct
24 Correct 6 ms 344 KB Output is correct
25 Correct 17 ms 600 KB Output is correct
26 Correct 15 ms 344 KB Output is correct
27 Correct 13 ms 344 KB Output is correct
28 Correct 3 ms 852 KB Output is correct
29 Correct 22 ms 344 KB Output is correct
30 Correct 10 ms 440 KB Output is correct
31 Correct 16 ms 440 KB Output is correct
32 Correct 11 ms 444 KB Output is correct
33 Correct 16 ms 344 KB Output is correct
34 Correct 14 ms 344 KB Output is correct
35 Correct 18 ms 444 KB Output is correct
36 Correct 16 ms 600 KB Output is correct
37 Correct 14 ms 344 KB Output is correct
38 Correct 14 ms 856 KB Output is correct
39 Correct 12 ms 344 KB Output is correct
40 Correct 11 ms 456 KB Output is correct
41 Correct 6 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 30 ms 816 KB Output is correct
8 Correct 11 ms 600 KB Output is correct
9 Correct 42 ms 552 KB Output is correct
10 Correct 30 ms 440 KB Output is correct
11 Correct 24 ms 600 KB Output is correct
12 Correct 19 ms 600 KB Output is correct
13 Correct 25 ms 432 KB Output is correct
14 Correct 31 ms 532 KB Output is correct
15 Correct 24 ms 788 KB Output is correct
16 Correct 31 ms 732 KB Output is correct
17 Correct 44 ms 780 KB Output is correct
18 Correct 32 ms 548 KB Output is correct
19 Partially correct 36 ms 556 KB Output is partially correct
20 Correct 36 ms 444 KB Output is correct
21 Correct 30 ms 696 KB Output is correct
22 Correct 29 ms 600 KB Output is correct
23 Correct 32 ms 600 KB Output is correct
24 Correct 20 ms 460 KB Output is correct
25 Correct 17 ms 604 KB Output is correct
26 Correct 10 ms 740 KB Output is correct
27 Correct 29 ms 444 KB Output is correct
28 Correct 17 ms 516 KB Output is correct
29 Partially correct 45 ms 436 KB Output is partially correct
30 Partially correct 41 ms 776 KB Output is partially correct
31 Correct 17 ms 344 KB Output is correct
32 Correct 37 ms 544 KB Output is correct
33 Correct 33 ms 792 KB Output is correct
34 Correct 49 ms 484 KB Output is correct
35 Partially correct 42 ms 592 KB Output is partially correct
36 Partially correct 28 ms 592 KB Output is partially correct
37 Correct 43 ms 800 KB Output is correct
38 Correct 31 ms 444 KB Output is correct
39 Correct 25 ms 344 KB Output is correct
40 Correct 34 ms 600 KB Output is correct
41 Partially correct 33 ms 344 KB Output is partially correct
42 Partially correct 27 ms 592 KB Output is partially correct
43 Correct 5 ms 344 KB Output is correct
44 Correct 20 ms 444 KB Output is correct
45 Correct 31 ms 556 KB Output is correct
46 Correct 21 ms 956 KB Output is correct
47 Correct 15 ms 344 KB Output is correct
48 Correct 21 ms 468 KB Output is correct