Submission #629090

# Submission time Handle Problem Language Result Execution time Memory
629090 2022-08-14T07:22:21 Z handlename Rarest Insects (IOI22_insects) C++17
99.89 / 100
71 ms 1380 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
#define pb push_back
#define mp make_pair
set<int> s;
set<int> lol[2001];
void add(int i){
	move_inside(i);
	s.insert(i);
}
void rem(int i){
	move_outside(i);
	s.erase(i);
}
int min_cardinality(int n){
	for (int i=0;i<n;i++){
		add(i);
		if (press_button()>1){
			rem(i);
		}
		lol[n].insert(i);
	}
	int mini=1,maxi=n/s.size()+1,sz=s.size();
	while (mini+1<maxi){
		int mid=(mini+maxi)/2;
		set<int> added;
		int id=mid;
		for (int i=mid;i<=n;i++){
			if (!lol[i].empty()){
				id=i;
				break;
			}
		}
		for (auto i:lol[id]){
			if (s.find(i)!=s.end()) continue;
			add(i);
			if (press_button()>mid) rem(i);
			else added.insert(i);
		}
		lol[mid]=s;
		if ((int)s.size()==sz*mid){
			mini=mid;
		}
		else {
			maxi=mid;
			for (auto i:added) rem(i);
		}
	}
	return mini;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 4 ms 424 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 6 ms 412 KB Output is correct
9 Correct 8 ms 336 KB Output is correct
10 Correct 6 ms 464 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 8 ms 420 KB Output is correct
14 Correct 8 ms 432 KB Output is correct
15 Correct 7 ms 416 KB Output is correct
16 Correct 9 ms 396 KB Output is correct
17 Correct 5 ms 416 KB Output is correct
18 Correct 6 ms 336 KB Output is correct
19 Correct 3 ms 400 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 4 ms 424 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 6 ms 412 KB Output is correct
9 Correct 8 ms 336 KB Output is correct
10 Correct 6 ms 464 KB Output is correct
11 Correct 3 ms 336 KB Output is correct
12 Correct 4 ms 336 KB Output is correct
13 Correct 8 ms 420 KB Output is correct
14 Correct 8 ms 432 KB Output is correct
15 Correct 7 ms 416 KB Output is correct
16 Correct 9 ms 396 KB Output is correct
17 Correct 5 ms 416 KB Output is correct
18 Correct 6 ms 336 KB Output is correct
19 Correct 3 ms 400 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 3 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 22 ms 804 KB Output is correct
24 Correct 9 ms 464 KB Output is correct
25 Correct 21 ms 664 KB Output is correct
26 Correct 35 ms 568 KB Output is correct
27 Correct 28 ms 540 KB Output is correct
28 Correct 9 ms 432 KB Output is correct
29 Correct 23 ms 420 KB Output is correct
30 Correct 27 ms 452 KB Output is correct
31 Correct 29 ms 668 KB Output is correct
32 Correct 21 ms 664 KB Output is correct
33 Correct 30 ms 664 KB Output is correct
34 Correct 32 ms 696 KB Output is correct
35 Correct 19 ms 588 KB Output is correct
36 Correct 26 ms 600 KB Output is correct
37 Correct 25 ms 460 KB Output is correct
38 Correct 38 ms 484 KB Output is correct
39 Correct 24 ms 596 KB Output is correct
40 Correct 16 ms 432 KB Output is correct
41 Correct 11 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 0 ms 336 KB Output is correct
7 Correct 63 ms 1380 KB Output is correct
8 Correct 17 ms 444 KB Output is correct
9 Correct 59 ms 1000 KB Output is correct
10 Correct 48 ms 740 KB Output is correct
11 Correct 51 ms 484 KB Output is correct
12 Correct 31 ms 516 KB Output is correct
13 Correct 40 ms 572 KB Output is correct
14 Correct 54 ms 664 KB Output is correct
15 Correct 56 ms 1168 KB Output is correct
16 Correct 59 ms 1188 KB Output is correct
17 Correct 56 ms 1080 KB Output is correct
18 Correct 61 ms 1076 KB Output is correct
19 Partially correct 51 ms 1068 KB Output is partially correct
20 Correct 64 ms 1056 KB Output is correct
21 Correct 42 ms 716 KB Output is correct
22 Correct 44 ms 680 KB Output is correct
23 Correct 27 ms 496 KB Output is correct
24 Correct 46 ms 636 KB Output is correct
25 Correct 26 ms 528 KB Output is correct
26 Correct 21 ms 536 KB Output is correct
27 Correct 51 ms 812 KB Output is correct
28 Correct 49 ms 816 KB Output is correct
29 Partially correct 61 ms 1060 KB Output is partially correct
30 Partially correct 54 ms 1008 KB Output is partially correct
31 Correct 60 ms 684 KB Output is correct
32 Correct 43 ms 696 KB Output is correct
33 Correct 49 ms 536 KB Output is correct
34 Correct 54 ms 564 KB Output is correct
35 Partially correct 56 ms 932 KB Output is partially correct
36 Partially correct 49 ms 944 KB Output is partially correct
37 Correct 56 ms 736 KB Output is correct
38 Correct 59 ms 684 KB Output is correct
39 Correct 71 ms 816 KB Output is correct
40 Correct 35 ms 924 KB Output is correct
41 Partially correct 65 ms 932 KB Output is partially correct
42 Partially correct 60 ms 988 KB Output is partially correct
43 Correct 15 ms 408 KB Output is correct
44 Correct 21 ms 396 KB Output is correct
45 Correct 51 ms 1328 KB Output is correct
46 Correct 35 ms 552 KB Output is correct
47 Correct 30 ms 504 KB Output is correct
48 Correct 35 ms 452 KB Output is correct