답안 #632101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632101 2022-08-19T12:31:46 Z Mahtimursu 드문 곤충 (IOI22_insects) C++17
100 / 100
57 ms 328 KB
#include "insects.h"
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
vector<int> v; 
int inside = 0;
 
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
 
int min_cardinality(int n) {
    int uniq = 0;
    for (int i = 0; i < n; ++i) {
        move_inside(i);
 
        if (press_button() > 1) {
            move_outside(i);
            v.push_back(i);
        } else uniq++;
    }
 
    if (uniq == 1) return n;
    if (uniq > n / 2) return 1;
 
    inside = uniq;
    int left = 1;
    int right = n / uniq;
 
    while (left < right) {
        int mid = (left + right + 1) / 2;
        
        vector<int> in;
 
        int mx = mid;
        int gc = 0;

        shuffle(v.begin(), v.end(), rng);
 
        for (int x : v) {
            move_inside(x);
 
            if (press_button() > mx) {
                move_outside(x);
            } else {
                in.push_back(x);
                gc++;
            }

            if ((inside + gc) / mx == uniq) break;
        }
 
        if ((inside + gc) / mx == uniq) {
            inside += gc;
            for (int x : in) v.erase(find(v.begin(), v.end(), x));
            left = mid;
        } else {
            v = in;
            right = mid - 1;
            for (int x : in) move_outside(x);
        }

        //cout << v.size() << endl;
    }
 
    return left;
}
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 304 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 304 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 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 0 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 304 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 304 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 5 ms 208 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 9 ms 208 KB Output is correct
25 Correct 18 ms 308 KB Output is correct
26 Correct 22 ms 304 KB Output is correct
27 Correct 23 ms 208 KB Output is correct
28 Correct 8 ms 208 KB Output is correct
29 Correct 27 ms 208 KB Output is correct
30 Correct 30 ms 300 KB Output is correct
31 Correct 17 ms 208 KB Output is correct
32 Correct 18 ms 304 KB Output is correct
33 Correct 23 ms 208 KB Output is correct
34 Correct 19 ms 208 KB Output is correct
35 Correct 27 ms 308 KB Output is correct
36 Correct 19 ms 304 KB Output is correct
37 Correct 18 ms 308 KB Output is correct
38 Correct 16 ms 304 KB Output is correct
39 Correct 18 ms 304 KB Output is correct
40 Correct 14 ms 208 KB Output is correct
41 Correct 8 ms 304 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 0 ms 208 KB Output is correct
7 Correct 17 ms 208 KB Output is correct
8 Correct 18 ms 208 KB Output is correct
9 Correct 41 ms 312 KB Output is correct
10 Correct 49 ms 208 KB Output is correct
11 Correct 20 ms 312 KB Output is correct
12 Correct 20 ms 208 KB Output is correct
13 Correct 56 ms 312 KB Output is correct
14 Correct 45 ms 316 KB Output is correct
15 Correct 36 ms 300 KB Output is correct
16 Correct 41 ms 208 KB Output is correct
17 Correct 37 ms 208 KB Output is correct
18 Correct 49 ms 208 KB Output is correct
19 Correct 41 ms 208 KB Output is correct
20 Correct 46 ms 208 KB Output is correct
21 Correct 51 ms 308 KB Output is correct
22 Correct 50 ms 312 KB Output is correct
23 Correct 29 ms 308 KB Output is correct
24 Correct 31 ms 308 KB Output is correct
25 Correct 21 ms 300 KB Output is correct
26 Correct 18 ms 208 KB Output is correct
27 Correct 43 ms 208 KB Output is correct
28 Correct 40 ms 300 KB Output is correct
29 Correct 44 ms 208 KB Output is correct
30 Correct 33 ms 328 KB Output is correct
31 Correct 47 ms 308 KB Output is correct
32 Correct 57 ms 208 KB Output is correct
33 Correct 48 ms 208 KB Output is correct
34 Correct 36 ms 208 KB Output is correct
35 Correct 39 ms 308 KB Output is correct
36 Correct 47 ms 296 KB Output is correct
37 Correct 29 ms 208 KB Output is correct
38 Correct 53 ms 292 KB Output is correct
39 Correct 19 ms 312 KB Output is correct
40 Correct 37 ms 300 KB Output is correct
41 Correct 30 ms 208 KB Output is correct
42 Correct 39 ms 304 KB Output is correct
43 Correct 14 ms 208 KB Output is correct
44 Correct 33 ms 208 KB Output is correct
45 Correct 33 ms 312 KB Output is correct
46 Correct 23 ms 208 KB Output is correct
47 Correct 22 ms 308 KB Output is correct
48 Correct 21 ms 300 KB Output is correct