Submission #852464

# Submission time Handle Problem Language Result Execution time Memory
852464 2023-09-21T20:28:29 Z fadi57 Rarest Insects (IOI22_insects) C++17
47.51 / 100
122 ms 1728 KB
#include<bits/stdc++.h>
#include "insects.h"
using namespace std;
int n;
const int mx=2e7+10;
map<int,int>in;
int sz=0;
int d=0;
/*
bool check(int x)
{
  vector<int>removee;
    for(int i=0; i<n; i++)
    {
           if(in[i]){

           }else{
                move_inside(i);
              int z=press_button();
               if(z>x)
                    {
                  move_outside(i);
                   }else{
                     removee.push_back(i);
                   }
           }

       }
    int z=press_button();
   for(auto it:removee){
    move_outside(*it);
   }
    if(removee.size()==d*(x-1))
    {
        return 1;
    }
    else
    {
        return 0;
    }

}*/
int min_cardinality(int N)
{
    int arr[N+1];
    n=N;
    for(int i=0; i<N; i++)
    {
        arr[i]=-1;
    }

vector<int>v;
    for(int i=0; i<N; i++)
    {
        move_inside(i);
        //in[i]=1;
        d++;
        int z=  press_button();
        if(z>1)
        {
            move_outside(i);
            in[i]=0;
            d--;
        }
        else
        {
            v.push_back(i);
            sz++;
        }


    }
    int l=1;
    int r=N/d;
    int ans=-1;
    while(l<=r)
    {
        int mid=(l+r)/2;
        sz=0;
        vector<int> to_remove;
       for (int i = 0; i < N; i++) {
			if (!binary_search(v.begin(), v.end(), i)) {
				move_inside(i);
				if (press_button() > mid) {
					move_outside(i);
				} else {
					to_remove.push_back(i);
				}
			}
		}
		if ((int)to_remove.size() == (int)v.size() * (mid - 1)) {
			ans = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
		for (auto i : to_remove) {
			move_outside(i);
		}


    }
    return ans;


}
/*
int main(){
cout<<min_cardinality(9);


}*/

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:9: warning: variable 'arr' set but not used [-Wunused-but-set-variable]
   45 |     int arr[N+1];
      |         ^~~
# Verdict Execution time Memory 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 8 ms 448 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 440 KB Output is correct
9 Correct 4 ms 608 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 6 ms 440 KB Output is correct
13 Correct 4 ms 600 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 5 ms 696 KB Output is correct
16 Correct 5 ms 860 KB Output is correct
17 Correct 4 ms 600 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory 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 8 ms 448 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 4 ms 440 KB Output is correct
9 Correct 4 ms 608 KB Output is correct
10 Correct 6 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 6 ms 440 KB Output is correct
13 Correct 4 ms 600 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 5 ms 696 KB Output is correct
16 Correct 5 ms 860 KB Output is correct
17 Correct 4 ms 600 KB Output is correct
18 Correct 3 ms 344 KB Output is correct
19 Correct 3 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 45 ms 972 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 33 ms 1112 KB Output is correct
26 Correct 25 ms 892 KB Output is correct
27 Correct 49 ms 856 KB Output is correct
28 Correct 9 ms 856 KB Output is correct
29 Correct 41 ms 724 KB Output is correct
30 Correct 33 ms 1112 KB Output is correct
31 Correct 55 ms 716 KB Output is correct
32 Correct 40 ms 928 KB Output is correct
33 Correct 41 ms 980 KB Output is correct
34 Correct 44 ms 868 KB Output is correct
35 Correct 33 ms 1124 KB Output is correct
36 Correct 29 ms 1216 KB Output is correct
37 Correct 29 ms 720 KB Output is correct
38 Correct 26 ms 856 KB Output is correct
39 Correct 17 ms 856 KB Output is correct
40 Correct 14 ms 600 KB Output is correct
41 Correct 6 ms 864 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 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 Partially correct 122 ms 908 KB Output is partially correct
8 Correct 9 ms 604 KB Output is correct
9 Partially correct 70 ms 1132 KB Output is partially correct
10 Partially correct 61 ms 1368 KB Output is partially correct
11 Partially correct 114 ms 676 KB Output is partially correct
12 Correct 19 ms 856 KB Output is correct
13 Partially correct 111 ms 1372 KB Output is partially correct
14 Partially correct 57 ms 1436 KB Output is partially correct
15 Partially correct 95 ms 1180 KB Output is partially correct
16 Partially correct 105 ms 1380 KB Output is partially correct
17 Partially correct 90 ms 1012 KB Output is partially correct
18 Partially correct 75 ms 1368 KB Output is partially correct
19 Partially correct 86 ms 1728 KB Output is partially correct
20 Partially correct 81 ms 1500 KB Output is partially correct
21 Partially correct 62 ms 1028 KB Output is partially correct
22 Partially correct 56 ms 1140 KB Output is partially correct
23 Partially correct 33 ms 856 KB Output is partially correct
24 Correct 27 ms 1364 KB Output is correct
25 Correct 21 ms 972 KB Output is correct
26 Correct 15 ms 856 KB Output is correct
27 Partially correct 69 ms 1112 KB Output is partially correct
28 Partially correct 70 ms 980 KB Output is partially correct
29 Partially correct 88 ms 1136 KB Output is partially correct
30 Partially correct 85 ms 1116 KB Output is partially correct
31 Partially correct 55 ms 1268 KB Output is partially correct
32 Partially correct 62 ms 964 KB Output is partially correct
33 Partially correct 46 ms 1368 KB Output is partially correct
34 Partially correct 57 ms 1112 KB Output is partially correct
35 Partially correct 65 ms 1020 KB Output is partially correct
36 Partially correct 72 ms 1112 KB Output is partially correct
37 Partially correct 60 ms 1016 KB Output is partially correct
38 Partially correct 64 ms 1112 KB Output is partially correct
39 Partially correct 54 ms 1624 KB Output is partially correct
40 Partially correct 56 ms 1216 KB Output is partially correct
41 Partially correct 67 ms 1248 KB Output is partially correct
42 Partially correct 64 ms 1368 KB Output is partially correct
43 Partially correct 19 ms 856 KB Output is partially correct
44 Partially correct 75 ms 1124 KB Output is partially correct
45 Partially correct 111 ms 1660 KB Output is partially correct
46 Correct 18 ms 856 KB Output is correct
47 Correct 21 ms 856 KB Output is correct
48 Correct 21 ms 972 KB Output is correct