Submission #852330

# Submission time Handle Problem Language Result Execution time Memory
852330 2023-09-21T15:30:03 Z fadi57 Rarest Insects (IOI22_insects) C++17
47.51 / 100
139 ms 1876 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;
    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 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 8 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 7 ms 856 KB Output is correct
9 Correct 8 ms 856 KB Output is correct
10 Correct 8 ms 600 KB Output is correct
11 Correct 6 ms 600 KB Output is correct
12 Correct 10 ms 600 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 7 ms 600 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 6 ms 344 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 4 ms 344 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 Correct 8 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 7 ms 856 KB Output is correct
9 Correct 8 ms 856 KB Output is correct
10 Correct 8 ms 600 KB Output is correct
11 Correct 6 ms 600 KB Output is correct
12 Correct 10 ms 600 KB Output is correct
13 Correct 7 ms 344 KB Output is correct
14 Correct 7 ms 600 KB Output is correct
15 Correct 7 ms 600 KB Output is correct
16 Correct 6 ms 344 KB Output is correct
17 Correct 8 ms 856 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 6 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 51 ms 1632 KB Output is correct
24 Correct 5 ms 440 KB Output is correct
25 Correct 52 ms 1456 KB Output is correct
26 Correct 49 ms 1220 KB Output is correct
27 Correct 53 ms 856 KB Output is correct
28 Correct 33 ms 856 KB Output is correct
29 Correct 52 ms 600 KB Output is correct
30 Correct 51 ms 1224 KB Output is correct
31 Correct 49 ms 968 KB Output is correct
32 Correct 51 ms 1348 KB Output is correct
33 Correct 53 ms 856 KB Output is correct
34 Correct 51 ms 1688 KB Output is correct
35 Correct 51 ms 968 KB Output is correct
36 Correct 50 ms 888 KB Output is correct
37 Correct 53 ms 976 KB Output is correct
38 Correct 51 ms 1120 KB Output is correct
39 Correct 40 ms 1044 KB Output is correct
40 Correct 35 ms 956 KB Output is correct
41 Correct 23 ms 456 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 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Partially correct 0 ms 344 KB Output is partially correct
7 Partially correct 120 ms 1740 KB Output is partially correct
8 Correct 10 ms 600 KB Output is correct
9 Partially correct 129 ms 1392 KB Output is partially correct
10 Partially correct 119 ms 1488 KB Output is partially correct
11 Partially correct 121 ms 1736 KB Output is partially correct
12 Partially correct 67 ms 1208 KB Output is partially correct
13 Partially correct 114 ms 1876 KB Output is partially correct
14 Partially correct 120 ms 1164 KB Output is partially correct
15 Partially correct 139 ms 1012 KB Output is partially correct
16 Partially correct 126 ms 1268 KB Output is partially correct
17 Partially correct 113 ms 1492 KB Output is partially correct
18 Partially correct 125 ms 1360 KB Output is partially correct
19 Partially correct 113 ms 1488 KB Output is partially correct
20 Partially correct 116 ms 1504 KB Output is partially correct
21 Partially correct 131 ms 1632 KB Output is partially correct
22 Partially correct 113 ms 1656 KB Output is partially correct
23 Partially correct 107 ms 1004 KB Output is partially correct
24 Partially correct 95 ms 1244 KB Output is partially correct
25 Partially correct 74 ms 1224 KB Output is partially correct
26 Partially correct 52 ms 1216 KB Output is partially correct
27 Partially correct 113 ms 1368 KB Output is partially correct
28 Partially correct 111 ms 1012 KB Output is partially correct
29 Partially correct 118 ms 1372 KB Output is partially correct
30 Partially correct 114 ms 1384 KB Output is partially correct
31 Partially correct 121 ms 1464 KB Output is partially correct
32 Partially correct 112 ms 1468 KB Output is partially correct
33 Partially correct 113 ms 1644 KB Output is partially correct
34 Partially correct 118 ms 1736 KB Output is partially correct
35 Partially correct 120 ms 1624 KB Output is partially correct
36 Partially correct 115 ms 1260 KB Output is partially correct
37 Partially correct 124 ms 1484 KB Output is partially correct
38 Partially correct 118 ms 1124 KB Output is partially correct
39 Partially correct 119 ms 1004 KB Output is partially correct
40 Partially correct 125 ms 772 KB Output is partially correct
41 Partially correct 120 ms 1236 KB Output is partially correct
42 Partially correct 115 ms 1220 KB Output is partially correct
43 Partially correct 26 ms 600 KB Output is partially correct
44 Partially correct 124 ms 952 KB Output is partially correct
45 Partially correct 115 ms 1160 KB Output is partially correct
46 Partially correct 66 ms 1444 KB Output is partially correct
47 Partially correct 66 ms 1640 KB Output is partially correct
48 Partially correct 68 ms 1476 KB Output is partially correct