답안 #1074603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074603 2024-08-25T11:23:01 Z Nicolaikrob 드문 곤충 (IOI22_insects) C++17
99.89 / 100
54 ms 1180 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;

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

void mo(int i) {
    move_outside(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(x);
        }
        il -= M.size();
        rc += M.size()/tc;
        M.clear();
    }
    else {
        IU = M;
        il = M.size();
        for(auto x : M)
            move_outside(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;
    for(int i = 0; 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 1 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 2 ms 436 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 4 ms 440 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 4 ms 600 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 2 ms 436 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 2 ms 856 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 4 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 3 ms 344 KB Output is correct
16 Correct 4 ms 440 KB Output is correct
17 Correct 4 ms 344 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 344 KB Output is correct
20 Correct 4 ms 600 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 1 ms 352 KB Output is correct
23 Correct 17 ms 344 KB Output is correct
24 Correct 6 ms 468 KB Output is correct
25 Correct 12 ms 600 KB Output is correct
26 Correct 23 ms 436 KB Output is correct
27 Correct 15 ms 432 KB Output is correct
28 Correct 8 ms 456 KB Output is correct
29 Correct 17 ms 344 KB Output is correct
30 Correct 20 ms 672 KB Output is correct
31 Correct 22 ms 500 KB Output is correct
32 Correct 15 ms 600 KB Output is correct
33 Correct 18 ms 600 KB Output is correct
34 Correct 19 ms 480 KB Output is correct
35 Correct 18 ms 436 KB Output is correct
36 Correct 19 ms 428 KB Output is correct
37 Correct 16 ms 344 KB Output is correct
38 Correct 12 ms 692 KB Output is correct
39 Correct 16 ms 600 KB Output is correct
40 Correct 11 ms 344 KB Output is correct
41 Correct 4 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 596 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 1 ms 344 KB Output is correct
7 Correct 37 ms 680 KB Output is correct
8 Correct 9 ms 856 KB Output is correct
9 Correct 38 ms 544 KB Output is correct
10 Correct 41 ms 672 KB Output is correct
11 Correct 28 ms 688 KB Output is correct
12 Correct 24 ms 452 KB Output is correct
13 Correct 45 ms 424 KB Output is correct
14 Correct 32 ms 344 KB Output is correct
15 Correct 40 ms 848 KB Output is correct
16 Correct 35 ms 408 KB Output is correct
17 Correct 47 ms 412 KB Output is correct
18 Correct 47 ms 412 KB Output is correct
19 Partially correct 26 ms 600 KB Output is partially correct
20 Correct 47 ms 1180 KB Output is correct
21 Correct 22 ms 532 KB Output is correct
22 Correct 40 ms 428 KB Output is correct
23 Correct 37 ms 440 KB Output is correct
24 Correct 22 ms 452 KB Output is correct
25 Correct 17 ms 464 KB Output is correct
26 Correct 10 ms 600 KB Output is correct
27 Correct 36 ms 948 KB Output is correct
28 Correct 17 ms 528 KB Output is correct
29 Partially correct 37 ms 668 KB Output is partially correct
30 Partially correct 37 ms 412 KB Output is partially correct
31 Correct 31 ms 516 KB Output is correct
32 Correct 34 ms 668 KB Output is correct
33 Correct 37 ms 440 KB Output is correct
34 Correct 28 ms 592 KB Output is correct
35 Partially correct 43 ms 512 KB Output is partially correct
36 Partially correct 48 ms 432 KB Output is partially correct
37 Correct 32 ms 672 KB Output is correct
38 Correct 34 ms 544 KB Output is correct
39 Correct 47 ms 536 KB Output is correct
40 Correct 39 ms 416 KB Output is correct
41 Partially correct 54 ms 684 KB Output is partially correct
42 Partially correct 40 ms 524 KB Output is partially correct
43 Correct 6 ms 464 KB Output is correct
44 Correct 25 ms 428 KB Output is correct
45 Correct 42 ms 928 KB Output is correct
46 Correct 19 ms 696 KB Output is correct
47 Correct 9 ms 344 KB Output is correct
48 Correct 20 ms 872 KB Output is correct