Submission #798976

# Submission time Handle Problem Language Result Execution time Memory
798976 2023-07-31T08:17:10 Z AlphaBruh Rarest Insects (IOI22_insects) C++17
99.76 / 100
53 ms 420 KB
#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
int k = 0;
int min_cardinality(int n) {
	move_inside(0);
	k++;
	vector<bool>in_m(2001,0);
	in_m[0]=1;
	for(int i = 1; i < n; i++){
		move_inside(i);
		int rt = press_button();
		if(rt==2){
			move_outside(i);
		}
		else{
			k++;
			in_m[i]=1;
		}
	}
	int ansl = 0, ansr = n/k,inmn=0,linmn;
	vector<int>nc;
	for(int i = 0; i < n; i++){
		nc.push_back(i);
	}

	while(ansl < ansr){
		linmn=inmn;
		int mid =ansl+((nc.size()/k)+1)/2;
		vector<int>im;
		vector<int>om;
		for(int i : nc){
			if(in_m[i]){
				inmn++;
				im.push_back(i);
				continue;
			}
			move_inside(i);
			int rt = press_button();
			if(rt > mid){
				move_outside(i);
				om.push_back(i);
			}
			else{
				in_m[i]=1;
				im.push_back(i);
				inmn++;
			}
		}
		if(inmn < k*mid){
			inmn = linmn;
			ansr = mid-1;
			for(int i : im){
				in_m[i]=0;
				move_outside(i);
			}
			nc.assign(im.begin(),im.end());
		}
		else{
			ansl = mid;
			nc.assign(om.begin(),om.end());
		}
	}
	return ansl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 6 ms 296 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 304 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 5 ms 292 KB Output is correct
14 Correct 6 ms 208 KB Output is correct
15 Correct 4 ms 296 KB Output is correct
16 Correct 4 ms 296 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 2 ms 420 KB Output is correct
21 Correct 4 ms 296 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 6 ms 296 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
9 Correct 5 ms 208 KB Output is correct
10 Correct 4 ms 304 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 4 ms 208 KB Output is correct
13 Correct 5 ms 292 KB Output is correct
14 Correct 6 ms 208 KB Output is correct
15 Correct 4 ms 296 KB Output is correct
16 Correct 4 ms 296 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 4 ms 208 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 2 ms 420 KB Output is correct
21 Correct 4 ms 296 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 27 ms 296 KB Output is correct
24 Correct 4 ms 208 KB Output is correct
25 Correct 11 ms 300 KB Output is correct
26 Correct 25 ms 208 KB Output is correct
27 Correct 20 ms 300 KB Output is correct
28 Correct 15 ms 208 KB Output is correct
29 Correct 23 ms 208 KB Output is correct
30 Correct 21 ms 296 KB Output is correct
31 Correct 25 ms 208 KB Output is correct
32 Correct 25 ms 284 KB Output is correct
33 Correct 17 ms 304 KB Output is correct
34 Correct 20 ms 292 KB Output is correct
35 Correct 22 ms 280 KB Output is correct
36 Correct 24 ms 208 KB Output is correct
37 Correct 23 ms 208 KB Output is correct
38 Correct 19 ms 308 KB Output is correct
39 Correct 22 ms 296 KB Output is correct
40 Correct 18 ms 288 KB Output is correct
41 Correct 9 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 208 KB Output is correct
7 Correct 40 ms 296 KB Output is correct
8 Correct 17 ms 208 KB Output is correct
9 Correct 38 ms 296 KB Output is correct
10 Correct 46 ms 276 KB Output is correct
11 Correct 37 ms 292 KB Output is correct
12 Correct 24 ms 292 KB Output is correct
13 Correct 35 ms 292 KB Output is correct
14 Correct 40 ms 288 KB Output is correct
15 Correct 31 ms 408 KB Output is correct
16 Correct 39 ms 208 KB Output is correct
17 Correct 46 ms 276 KB Output is correct
18 Correct 37 ms 280 KB Output is correct
19 Partially correct 39 ms 208 KB Output is partially correct
20 Correct 38 ms 208 KB Output is correct
21 Correct 21 ms 296 KB Output is correct
22 Correct 37 ms 296 KB Output is correct
23 Correct 40 ms 292 KB Output is correct
24 Correct 34 ms 296 KB Output is correct
25 Correct 22 ms 284 KB Output is correct
26 Correct 21 ms 284 KB Output is correct
27 Partially correct 48 ms 300 KB Output is partially correct
28 Partially correct 38 ms 300 KB Output is partially correct
29 Partially correct 41 ms 292 KB Output is partially correct
30 Partially correct 44 ms 328 KB Output is partially correct
31 Correct 34 ms 296 KB Output is correct
32 Correct 39 ms 280 KB Output is correct
33 Correct 40 ms 284 KB Output is correct
34 Correct 38 ms 300 KB Output is correct
35 Partially correct 52 ms 276 KB Output is partially correct
36 Partially correct 38 ms 208 KB Output is partially correct
37 Correct 38 ms 292 KB Output is correct
38 Correct 25 ms 300 KB Output is correct
39 Partially correct 50 ms 296 KB Output is partially correct
40 Partially correct 49 ms 292 KB Output is partially correct
41 Partially correct 50 ms 292 KB Output is partially correct
42 Partially correct 52 ms 284 KB Output is partially correct
43 Correct 11 ms 300 KB Output is correct
44 Correct 35 ms 292 KB Output is correct
45 Correct 53 ms 208 KB Output is correct
46 Correct 28 ms 292 KB Output is correct
47 Correct 33 ms 208 KB Output is correct
48 Correct 29 ms 276 KB Output is correct