답안 #1024521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024521 2024-07-16T06:55:35 Z vjudge1 드문 곤충 (IOI22_insects) C++17
61.06 / 100
93 ms 1012 KB
#include "insects.h"
#include <bits/stdc++.h>

#define ll long long
#define sz(s) (int)s.size()
#define pb push_back
#define in insert
#define lb lower_bound
#define ub upper_bound

using namespace std;

const int MAX=2e5+10;

vector<int> a;
int cnt[MAX];
set<int> st;

void solve(int l,int r,vector<int> b){
    if(b.empty())return;
    if(l==r){
        // cout<<l<<" "<<r<<" ";
        // for(int x:b)cout<<x<<" ";
        // cout<<"\n";
        cnt[l]+=sz(b);
        return;
    }
    int m=(l+r)/2;
    while(st.ub(m)!=st.end()&&*st.ub(m)<=r){
        move_outside(a[*st.ub(m)]);
        st.erase(st.ub(m));
    }
    vector<int> L,R;
    for(int i=l;i<=m;i++){
        if(!st.count(i))move_inside(a[i]);
        st.in(i);
    }
    // cout<<l<<" "<<r<<" "<<m<<"\n";
    // for(int i:st)cout<<i<<" ";
    // cout<<"\n";
    for(int i:b){
        move_inside(i);
        if(press_button()==2)L.pb(i);
        else R.pb(i);
        move_outside(i);
    }
    solve(l,m,L);
    solve(m+1,r,R);
}

int min_cardinality(int N){
    vector<int> b;
    for(int i=0;i<N;i++){
        move_inside(i);
        if(press_button()==2){
            b.pb(i);
            move_outside(i);
        }
        else{
            // cout<<i<<"\n";
            st.in(sz(a));
            a.pb(i);
        }
    }
    solve(0,sz(a)-1,b);
    int ans=N;
    for(int i=0;i<sz(a);i++)ans=min(ans,cnt[i]+1);
    return ans;
}
# 결과 실행 시간 메모리 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 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 6 ms 704 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 4 ms 456 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 6 ms 448 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 5 ms 456 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
9 Correct 6 ms 704 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 5 ms 344 KB Output is correct
12 Correct 4 ms 456 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 3 ms 452 KB Output is correct
15 Correct 4 ms 344 KB Output is correct
16 Correct 6 ms 448 KB Output is correct
17 Correct 6 ms 344 KB Output is correct
18 Correct 5 ms 456 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 4 ms 344 KB Output is correct
23 Correct 6 ms 452 KB Output is correct
24 Correct 5 ms 856 KB Output is correct
25 Correct 30 ms 592 KB Output is correct
26 Correct 23 ms 464 KB Output is correct
27 Correct 13 ms 452 KB Output is correct
28 Correct 23 ms 716 KB Output is correct
29 Correct 17 ms 700 KB Output is correct
30 Correct 27 ms 344 KB Output is correct
31 Correct 15 ms 600 KB Output is correct
32 Correct 21 ms 456 KB Output is correct
33 Correct 28 ms 600 KB Output is correct
34 Correct 21 ms 344 KB Output is correct
35 Correct 31 ms 344 KB Output is correct
36 Correct 26 ms 592 KB Output is correct
37 Correct 36 ms 612 KB Output is correct
38 Correct 40 ms 612 KB Output is correct
39 Correct 38 ms 344 KB Output is correct
40 Correct 30 ms 344 KB Output is correct
41 Correct 26 ms 488 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 Correct 0 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
8 Correct 8 ms 344 KB Output is correct
9 Partially correct 56 ms 600 KB Output is partially correct
10 Partially correct 51 ms 720 KB Output is partially correct
11 Correct 23 ms 592 KB Output is correct
12 Partially correct 68 ms 600 KB Output is partially correct
13 Partially correct 44 ms 956 KB Output is partially correct
14 Partially correct 75 ms 592 KB Output is partially correct
15 Partially correct 41 ms 696 KB Output is partially correct
16 Partially correct 50 ms 684 KB Output is partially correct
17 Partially correct 42 ms 720 KB Output is partially correct
18 Partially correct 46 ms 356 KB Output is partially correct
19 Partially correct 66 ms 600 KB Output is partially correct
20 Partially correct 75 ms 592 KB Output is partially correct
21 Partially correct 85 ms 472 KB Output is partially correct
22 Partially correct 85 ms 344 KB Output is partially correct
23 Partially correct 80 ms 852 KB Output is partially correct
24 Partially correct 88 ms 476 KB Output is partially correct
25 Partially correct 69 ms 344 KB Output is partially correct
26 Partially correct 49 ms 600 KB Output is partially correct
27 Partially correct 89 ms 852 KB Output is partially correct
28 Partially correct 72 ms 716 KB Output is partially correct
29 Partially correct 67 ms 472 KB Output is partially correct
30 Partially correct 67 ms 708 KB Output is partially correct
31 Partially correct 66 ms 344 KB Output is partially correct
32 Partially correct 67 ms 460 KB Output is partially correct
33 Partially correct 79 ms 468 KB Output is partially correct
34 Partially correct 88 ms 712 KB Output is partially correct
35 Partially correct 69 ms 848 KB Output is partially correct
36 Partially correct 87 ms 456 KB Output is partially correct
37 Partially correct 84 ms 452 KB Output is partially correct
38 Partially correct 93 ms 600 KB Output is partially correct
39 Partially correct 87 ms 476 KB Output is partially correct
40 Partially correct 74 ms 600 KB Output is partially correct
41 Partially correct 72 ms 344 KB Output is partially correct
42 Partially correct 79 ms 708 KB Output is partially correct
43 Partially correct 10 ms 456 KB Output is partially correct
44 Partially correct 35 ms 456 KB Output is partially correct
45 Correct 17 ms 460 KB Output is correct
46 Partially correct 71 ms 1012 KB Output is partially correct
47 Partially correct 58 ms 956 KB Output is partially correct
48 Partially correct 62 ms 764 KB Output is partially correct