답안 #736478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736478 2023-05-05T17:37:19 Z puppy 드문 곤충 (IOI22_insects) C++17
100 / 100
73 ms 576 KB
#include "insects.h"
#include <vector>
#include <set>
#include <iostream>
using namespace std;
int dc[2005];
int min_cardinality(int N) {
    set<int> st;
    for (int i = 0; i < N; i++) {
        move_inside(i);
        st.insert(i);
        if (press_button() > 1) {
            move_outside(i);
            st.erase(i);
        }
        else {
            dc[i] = 1;
        }
    }
    int S = st.size();
    int l = 1, r = N / S;
    while (l < r) {
        int m = l + r + 1 + (r - l > 10) >> 1;
        for (int i = 0; i < N; i++) {
            if (dc[i] == 1 || dc[i] == 2) continue;
            move_inside(i);
            st.insert(i);
            if (press_button() > m) {
                move_outside(i);
                st.erase(i);
            }
            else {
                dc[i] = 3;
            }
        }
        if (st.size() != m * S) {
            r = m - 1;
            for (int i = 0; i < N; i++) {
                if (dc[i] == 0) dc[i] = 2;
                else if (dc[i] == 3) dc[i] = 0;
            }
        }
        else {
            if ((m + 1) * S > N) return m;
            l = m;
            for (int i = 0; i < N; i++) {
                if (dc[i] == 3) dc[i] = 1;
            }
        }
        for (int i = 0; i < N; i++) {
            if (dc[i] != 1 && dc[i] != 2 && st.find(i) != st.end()) {
                st.erase(i);
                move_outside(i);
            }
        }
    }
    return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:23:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |         int m = l + r + 1 + (r - l > 10) >> 1;
      |                 ~~~~~~~~~~^~~~~~~~~~~~~~
insects.cpp:36:23: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |         if (st.size() != m * S) {
      |             ~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 5 ms 308 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 5 ms 300 KB Output is correct
9 Correct 7 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 5 ms 304 KB Output is correct
13 Correct 5 ms 208 KB Output is correct
14 Correct 9 ms 304 KB Output is correct
15 Correct 6 ms 308 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 312 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 4 ms 308 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 5 ms 308 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 5 ms 300 KB Output is correct
9 Correct 7 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 5 ms 304 KB Output is correct
13 Correct 5 ms 208 KB Output is correct
14 Correct 9 ms 304 KB Output is correct
15 Correct 6 ms 308 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 312 KB Output is correct
19 Correct 5 ms 208 KB Output is correct
20 Correct 4 ms 308 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 22 ms 328 KB Output is correct
24 Correct 9 ms 336 KB Output is correct
25 Correct 35 ms 332 KB Output is correct
26 Correct 30 ms 316 KB Output is correct
27 Correct 30 ms 300 KB Output is correct
28 Correct 11 ms 312 KB Output is correct
29 Correct 27 ms 296 KB Output is correct
30 Correct 32 ms 308 KB Output is correct
31 Correct 14 ms 316 KB Output is correct
32 Correct 31 ms 296 KB Output is correct
33 Correct 21 ms 328 KB Output is correct
34 Correct 34 ms 208 KB Output is correct
35 Correct 20 ms 316 KB Output is correct
36 Correct 38 ms 304 KB Output is correct
37 Correct 31 ms 304 KB Output is correct
38 Correct 29 ms 304 KB Output is correct
39 Correct 22 ms 316 KB Output is correct
40 Correct 12 ms 208 KB Output is correct
41 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 64 ms 340 KB Output is correct
8 Correct 21 ms 364 KB Output is correct
9 Correct 59 ms 344 KB Output is correct
10 Correct 52 ms 328 KB Output is correct
11 Correct 46 ms 308 KB Output is correct
12 Correct 19 ms 432 KB Output is correct
13 Correct 56 ms 304 KB Output is correct
14 Correct 72 ms 412 KB Output is correct
15 Correct 59 ms 332 KB Output is correct
16 Correct 48 ms 360 KB Output is correct
17 Correct 67 ms 280 KB Output is correct
18 Correct 28 ms 356 KB Output is correct
19 Correct 48 ms 364 KB Output is correct
20 Correct 40 ms 332 KB Output is correct
21 Correct 57 ms 576 KB Output is correct
22 Correct 49 ms 296 KB Output is correct
23 Correct 43 ms 308 KB Output is correct
24 Correct 51 ms 308 KB Output is correct
25 Correct 39 ms 444 KB Output is correct
26 Correct 21 ms 336 KB Output is correct
27 Correct 37 ms 444 KB Output is correct
28 Correct 56 ms 360 KB Output is correct
29 Correct 49 ms 296 KB Output is correct
30 Correct 53 ms 296 KB Output is correct
31 Correct 71 ms 296 KB Output is correct
32 Correct 64 ms 292 KB Output is correct
33 Correct 36 ms 284 KB Output is correct
34 Correct 73 ms 300 KB Output is correct
35 Correct 29 ms 460 KB Output is correct
36 Correct 58 ms 292 KB Output is correct
37 Correct 50 ms 296 KB Output is correct
38 Correct 60 ms 296 KB Output is correct
39 Correct 40 ms 288 KB Output is correct
40 Correct 44 ms 296 KB Output is correct
41 Correct 45 ms 296 KB Output is correct
42 Correct 65 ms 340 KB Output is correct
43 Correct 8 ms 428 KB Output is correct
44 Correct 42 ms 284 KB Output is correct
45 Correct 55 ms 496 KB Output is correct
46 Correct 27 ms 432 KB Output is correct
47 Correct 29 ms 352 KB Output is correct
48 Correct 25 ms 332 KB Output is correct