Submission #1024471

# Submission time Handle Problem Language Result Execution time Memory
1024471 2024-07-16T05:40:01 Z vjudge1 Rarest Insects (IOI22_insects) C++17
47.98 / 100
174 ms 1112 KB
#include <bits/stdc++.h>
#define ent '\n'

void move_inside(int i);
void move_outside(int i);
int press_button();

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 12;

struct Q{
    int mid, l, r, i;
};

int cnt[maxn];
bool is[maxn];
int p[maxn];

int min_cardinality(int n){
    vector<Q> q;
    vector<int> v;
    for(int i=0;i<n;i++){
        move_inside(i);
        if(press_button() != 1){
            move_outside(i);
            int l = 0, r = i - 1, mid = l + r >> 1;
            q.push_back({mid, l, r, i});
        }
        else{
            v.push_back(i);
            is[i] = 1;
            p[i] = i;
        }
    }
    while(v.size()){
        move_outside(v.back());
        v.pop_back();
    }
    while(q.size()){
        vector<Q> nq;
        sort(q.begin(), q.end(), [](Q x, Q y){
            return x.mid < y.mid;
        });
        int ptr = 0;
        vector<int> v;
        for(auto [mid, l, r, i]:q){
            while(ptr <= mid){
                if(is[ptr]){
                    v.push_back(ptr);
                    move_inside(ptr);
                }
                ptr++;
            }
            move_inside(i);
            if(press_button() != 1){
                r = mid - 1;
                p[i] = mid;
            }
            else l = mid + 1;
            move_outside(i);
            if(l <= r){
                int nmid = l + r >> 1;
                nq.push_back({nmid, l, r, i});
            }
        }
        while(v.size()){
            move_outside(v.back());
            v.pop_back();
        }
        q.swap(nq);
    }
    for(int i=0;i<n;i++){
        cnt[p[i]]++;
    }
    int ans = 1e9;
    for(int i=0;i<n;i++){
        if(p[i] == i){
            ans = min(ans, cnt[i]);
        }
    }
    return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:27:43: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |             int l = 0, r = i - 1, mid = l + r >> 1;
      |                                         ~~^~~
insects.cpp:63:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |                 int nmid = l + r >> 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 5 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 6 ms 464 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 5 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 9 ms 344 KB Output is correct
13 Correct 8 ms 464 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 6 ms 344 KB Output is correct
16 Correct 6 ms 456 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 4 ms 460 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 5 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 6 ms 464 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 5 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 9 ms 344 KB Output is correct
13 Correct 8 ms 464 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Correct 6 ms 344 KB Output is correct
16 Correct 6 ms 456 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 6 ms 600 KB Output is correct
20 Correct 9 ms 460 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 54 ms 980 KB Output is correct
24 Correct 4 ms 344 KB Output is correct
25 Correct 66 ms 740 KB Output is correct
26 Correct 50 ms 472 KB Output is correct
27 Correct 48 ms 484 KB Output is correct
28 Correct 21 ms 592 KB Output is correct
29 Correct 48 ms 724 KB Output is correct
30 Correct 57 ms 704 KB Output is correct
31 Correct 58 ms 480 KB Output is correct
32 Correct 59 ms 740 KB Output is correct
33 Correct 68 ms 736 KB Output is correct
34 Correct 56 ms 592 KB Output is correct
35 Correct 61 ms 644 KB Output is correct
36 Correct 64 ms 344 KB Output is correct
37 Correct 49 ms 736 KB Output is correct
38 Correct 60 ms 740 KB Output is correct
39 Correct 68 ms 736 KB Output is correct
40 Correct 38 ms 344 KB Output is correct
41 Correct 33 ms 452 KB Output is correct
# Verdict Execution time Memory 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 1 ms 344 KB Output is correct
5 Correct 0 ms 444 KB Output is correct
6 Partially correct 0 ms 344 KB Output is partially correct
7 Partially correct 118 ms 600 KB Output is partially correct
8 Correct 14 ms 708 KB Output is correct
9 Partially correct 135 ms 800 KB Output is partially correct
10 Partially correct 127 ms 592 KB Output is partially correct
11 Partially correct 115 ms 552 KB Output is partially correct
12 Partially correct 75 ms 616 KB Output is partially correct
13 Partially correct 125 ms 544 KB Output is partially correct
14 Partially correct 136 ms 544 KB Output is partially correct
15 Partially correct 137 ms 592 KB Output is partially correct
16 Partially correct 130 ms 768 KB Output is partially correct
17 Partially correct 125 ms 764 KB Output is partially correct
18 Partially correct 131 ms 592 KB Output is partially correct
19 Partially correct 119 ms 816 KB Output is partially correct
20 Partially correct 152 ms 504 KB Output is partially correct
21 Partially correct 133 ms 848 KB Output is partially correct
22 Partially correct 174 ms 600 KB Output is partially correct
23 Partially correct 143 ms 604 KB Output is partially correct
24 Partially correct 108 ms 344 KB Output is partially correct
25 Partially correct 103 ms 532 KB Output is partially correct
26 Partially correct 60 ms 732 KB Output is partially correct
27 Partially correct 135 ms 716 KB Output is partially correct
28 Partially correct 137 ms 624 KB Output is partially correct
29 Partially correct 132 ms 1016 KB Output is partially correct
30 Partially correct 160 ms 768 KB Output is partially correct
31 Partially correct 136 ms 564 KB Output is partially correct
32 Partially correct 126 ms 540 KB Output is partially correct
33 Partially correct 144 ms 988 KB Output is partially correct
34 Partially correct 136 ms 592 KB Output is partially correct
35 Partially correct 133 ms 716 KB Output is partially correct
36 Partially correct 123 ms 592 KB Output is partially correct
37 Partially correct 128 ms 844 KB Output is partially correct
38 Partially correct 134 ms 648 KB Output is partially correct
39 Partially correct 134 ms 592 KB Output is partially correct
40 Partially correct 116 ms 528 KB Output is partially correct
41 Partially correct 135 ms 592 KB Output is partially correct
42 Partially correct 130 ms 748 KB Output is partially correct
43 Partially correct 36 ms 968 KB Output is partially correct
44 Partially correct 149 ms 1112 KB Output is partially correct
45 Partially correct 143 ms 760 KB Output is partially correct
46 Partially correct 66 ms 600 KB Output is partially correct
47 Partially correct 70 ms 668 KB Output is partially correct
48 Partially correct 56 ms 592 KB Output is partially correct