Submission #859317

# Submission time Handle Problem Language Result Execution time Memory
859317 2023-10-10T03:56:39 Z kim Rarest Insects (IOI22_insects) C++17
56.41 / 100
98 ms 1824 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

#define in move_inside
#define press press_button
#define out move_outside

set<int> mp,mp2,mp3;
int n,p,k0;

bool check(int k1){
    stack<int> st;
    for(int i=0;i<n;++i){
        if(mp.count(i)) continue;
        if(mp3.count(i)) continue;
        in(i);
        if(press()>k1) out(i);
        else mp.insert(i),st.push(i);
    }
    if(mp.size()==p*k1){
        k0=k1;
        for(auto &e:mp) if(mp2.count(e)) mp2.erase(e);
        return 1;
    }
    stack<int> st2;
    for(auto &e:mp2){
        if(!mp.count(e)) st2.push(e);
    }
    while(!st2.empty()){
        mp2.erase(st2.top());
        mp3.insert(st2.top());
        st2.pop();
    }
    while(st.size()){
        mp.erase(st.top());
        out(st.top());
        st.pop();
    }
    return 0;
}

int min_cardinality(int N){
    n=N;
    for(int i=0;i<n;++i){
        in(i);
        if(press()>1) out(i),mp2.insert(i);
        else mp.insert(i);
    }
    p=mp.size();
    k0=1;

    int l=1,r=n;
    while(l<r){
        int mid=l+(r-l+1>>1);
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    return l;
}

Compilation message

insects.cpp: In function 'bool check(int)':
insects.cpp:22:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     if(mp.size()==p*k1){
      |        ~~~~~~~~~^~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:56:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   56 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 3 ms 600 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 5 ms 448 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 5 ms 600 KB Output is correct
19 Correct 5 ms 856 KB Output is correct
20 Correct 5 ms 856 KB Output is correct
21 Correct 4 ms 600 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 3 ms 600 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 4 ms 600 KB Output is correct
9 Correct 5 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 4 ms 600 KB Output is correct
13 Correct 5 ms 448 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 5 ms 600 KB Output is correct
19 Correct 5 ms 856 KB Output is correct
20 Correct 5 ms 856 KB Output is correct
21 Correct 4 ms 600 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 5 ms 1208 KB Output is correct
25 Correct 30 ms 1172 KB Output is correct
26 Correct 35 ms 1012 KB Output is correct
27 Correct 13 ms 1112 KB Output is correct
28 Correct 12 ms 1112 KB Output is correct
29 Correct 26 ms 616 KB Output is correct
30 Correct 35 ms 1380 KB Output is correct
31 Correct 21 ms 856 KB Output is correct
32 Correct 27 ms 1408 KB Output is correct
33 Correct 26 ms 864 KB Output is correct
34 Correct 29 ms 908 KB Output is correct
35 Correct 32 ms 1424 KB Output is correct
36 Correct 31 ms 1216 KB Output is correct
37 Correct 35 ms 1372 KB Output is correct
38 Correct 43 ms 1004 KB Output is correct
39 Correct 41 ms 992 KB Output is correct
40 Correct 28 ms 1228 KB Output is correct
41 Correct 20 ms 1368 KB Output is correct
# Verdict Execution time Memory 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 Partially correct 0 ms 344 KB Output is partially correct
7 Correct 30 ms 1232 KB Output is correct
8 Correct 12 ms 600 KB Output is correct
9 Partially correct 76 ms 856 KB Output is partially correct
10 Partially correct 86 ms 1240 KB Output is partially correct
11 Correct 29 ms 1016 KB Output is correct
12 Correct 21 ms 1112 KB Output is correct
13 Partially correct 50 ms 1092 KB Output is partially correct
14 Partially correct 78 ms 1484 KB Output is partially correct
15 Partially correct 45 ms 1508 KB Output is partially correct
16 Partially correct 59 ms 1264 KB Output is partially correct
17 Partially correct 57 ms 1420 KB Output is partially correct
18 Partially correct 59 ms 1272 KB Output is partially correct
19 Partially correct 70 ms 1260 KB Output is partially correct
20 Partially correct 76 ms 872 KB Output is partially correct
21 Partially correct 79 ms 1300 KB Output is partially correct
22 Partially correct 90 ms 1320 KB Output is partially correct
23 Partially correct 88 ms 1224 KB Output is partially correct
24 Partially correct 74 ms 1304 KB Output is partially correct
25 Partially correct 65 ms 1524 KB Output is partially correct
26 Partially correct 43 ms 1652 KB Output is partially correct
27 Partially correct 70 ms 988 KB Output is partially correct
28 Partially correct 67 ms 1108 KB Output is partially correct
29 Partially correct 64 ms 856 KB Output is partially correct
30 Partially correct 65 ms 856 KB Output is partially correct
31 Partially correct 91 ms 1200 KB Output is partially correct
32 Partially correct 90 ms 1508 KB Output is partially correct
33 Partially correct 98 ms 1440 KB Output is partially correct
34 Partially correct 89 ms 1160 KB Output is partially correct
35 Partially correct 71 ms 996 KB Output is partially correct
36 Partially correct 77 ms 944 KB Output is partially correct
37 Partially correct 84 ms 1624 KB Output is partially correct
38 Partially correct 91 ms 604 KB Output is partially correct
39 Partially correct 79 ms 852 KB Output is partially correct
40 Partially correct 74 ms 1824 KB Output is partially correct
41 Partially correct 73 ms 1112 KB Output is partially correct
42 Partially correct 73 ms 1524 KB Output is partially correct
43 Partially correct 8 ms 856 KB Output is partially correct
44 Partially correct 35 ms 960 KB Output is partially correct
45 Partially correct 37 ms 936 KB Output is partially correct
46 Correct 22 ms 1112 KB Output is correct
47 Correct 23 ms 1620 KB Output is correct
48 Correct 25 ms 1168 KB Output is correct