답안 #859271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859271 2023-10-10T02:56:53 Z kim 드문 곤충 (IOI22_insects) C++17
47.57 / 100
130 ms 1616 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;
int n,p,k0;

bool check(int k1){
    stack<int> st;
    for(int i=0;i<n;++i){
        if(mp.count(i)) continue;
        in(i);
        if(press()>k1) out(i);
        else mp.insert(i),st.push(i);
    }
    if(mp.size()==p*k1){
        k0=k1;
        return 1;
    }
    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);
        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:21:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     if(mp.size()==p*k1){
      |        ~~~~~~~~~^~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |         int mid=l+(r-l+1>>1);
      |                    ~~~^~
# 결과 실행 시간 메모리 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 3 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 5 ms 600 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 7 ms 696 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 5 ms 628 KB Output is correct
15 Correct 5 ms 600 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 5 ms 600 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 5 ms 600 KB Output is correct
22 Correct 3 ms 344 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 3 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 5 ms 600 KB Output is correct
9 Correct 6 ms 344 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 7 ms 696 KB Output is correct
13 Correct 6 ms 600 KB Output is correct
14 Correct 5 ms 628 KB Output is correct
15 Correct 5 ms 600 KB Output is correct
16 Correct 5 ms 600 KB Output is correct
17 Correct 5 ms 600 KB Output is correct
18 Correct 7 ms 344 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 5 ms 596 KB Output is correct
21 Correct 5 ms 600 KB Output is correct
22 Correct 3 ms 344 KB Output is correct
23 Correct 12 ms 692 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 29 ms 1360 KB Output is correct
26 Correct 41 ms 1148 KB Output is correct
27 Correct 46 ms 856 KB Output is correct
28 Correct 29 ms 856 KB Output is correct
29 Correct 47 ms 1204 KB Output is correct
30 Correct 41 ms 684 KB Output is correct
31 Correct 30 ms 1104 KB Output is correct
32 Correct 32 ms 960 KB Output is correct
33 Correct 30 ms 1212 KB Output is correct
34 Correct 30 ms 896 KB Output is correct
35 Correct 37 ms 664 KB Output is correct
36 Correct 41 ms 1112 KB Output is correct
37 Correct 51 ms 844 KB Output is correct
38 Correct 45 ms 708 KB Output is correct
39 Correct 38 ms 944 KB Output is correct
40 Correct 29 ms 852 KB Output is correct
41 Correct 21 ms 600 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 Partially correct 0 ms 344 KB Output is partially correct
7 Correct 32 ms 1132 KB Output is correct
8 Correct 9 ms 1368 KB Output is correct
9 Partially correct 77 ms 936 KB Output is partially correct
10 Partially correct 96 ms 1128 KB Output is partially correct
11 Partially correct 102 ms 848 KB Output is partially correct
12 Partially correct 53 ms 1112 KB Output is partially correct
13 Partially correct 130 ms 764 KB Output is partially correct
14 Partially correct 102 ms 976 KB Output is partially correct
15 Partially correct 41 ms 848 KB Output is partially correct
16 Partially correct 59 ms 908 KB Output is partially correct
17 Partially correct 63 ms 1224 KB Output is partially correct
18 Partially correct 63 ms 816 KB Output is partially correct
19 Partially correct 79 ms 756 KB Output is partially correct
20 Partially correct 77 ms 848 KB Output is partially correct
21 Partially correct 111 ms 1304 KB Output is partially correct
22 Partially correct 117 ms 948 KB Output is partially correct
23 Partially correct 98 ms 1256 KB Output is partially correct
24 Partially correct 93 ms 1112 KB Output is partially correct
25 Partially correct 79 ms 920 KB Output is partially correct
26 Partially correct 42 ms 1012 KB Output is partially correct
27 Partially correct 76 ms 860 KB Output is partially correct
28 Partially correct 70 ms 1496 KB Output is partially correct
29 Partially correct 70 ms 688 KB Output is partially correct
30 Partially correct 70 ms 656 KB Output is partially correct
31 Partially correct 103 ms 928 KB Output is partially correct
32 Partially correct 104 ms 1004 KB Output is partially correct
33 Partially correct 104 ms 1108 KB Output is partially correct
34 Partially correct 117 ms 1080 KB Output is partially correct
35 Partially correct 76 ms 984 KB Output is partially correct
36 Partially correct 76 ms 1196 KB Output is partially correct
37 Partially correct 96 ms 828 KB Output is partially correct
38 Partially correct 87 ms 1092 KB Output is partially correct
39 Partially correct 79 ms 1144 KB Output is partially correct
40 Partially correct 83 ms 964 KB Output is partially correct
41 Partially correct 63 ms 1004 KB Output is partially correct
42 Partially correct 83 ms 1172 KB Output is partially correct
43 Partially correct 30 ms 600 KB Output is partially correct
44 Partially correct 101 ms 668 KB Output is partially correct
45 Partially correct 47 ms 1468 KB Output is partially correct
46 Partially correct 67 ms 856 KB Output is partially correct
47 Partially correct 50 ms 1108 KB Output is partially correct
48 Partially correct 52 ms 1616 KB Output is partially correct