Submission #837143

# Submission time Handle Problem Language Result Execution time Memory
837143 2023-08-25T03:04:03 Z biank Rarest Insects (IOI22_insects) C++17
49.02 / 100
182 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define DBGY(x) cerr << #x << ": " << x << ", ";
#define DBG(x) cerr << #x << ": " << x << endl;

void move_inside(int i);
void move_outside(int i);
int press_button();

set <int> s;
vector <int> in, out;
int T;

bool check(int m, int &K) {
	int old_k = K;
	vector <int> v(ALL(s));
	random_shuffle(ALL(v));
	for (int i:v) {
		move_inside(i);
		if (press_button() <= m) {
			in.push_back(i);
			if (++K < m*T) {
				continue;
			}
			for (int j:in) {
				s.erase(j);
			}
			return true;
		} else {
			out.push_back(i);
			move_outside(i);
		}
	}
	for (int j:in) {
		move_outside(j);
	}
	for (int j:out) {
		s.erase(j);
	}
	K = old_k;
	return false;
}

int min_cardinality(int N) {
	srand(time(0));
	move_inside(0);
	in.push_back(0);
	s.insert(0);
	T = 1;
	for (int i=1; i<N; i++) {
		s.insert(i);
		move_inside(i);
		if (press_button() == 1) {
			in.push_back(i);
			T++;
		} else {
			move_outside(i);
		}
	}
	for (int i:in) {
		move_outside(i);
	}
	
	int K = 0, l = 0, r = N+1;
	
	while (l+1 < r) {
		in.clear();
		out.clear();
		int m = (l+r)/2;
		if (check(m, K)) {
			l = m;
		} else {
			r = m;
		}
	}
	
	return l;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 4 ms 300 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 8 ms 208 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
11 Correct 7 ms 208 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 11 ms 208 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 7 ms 208 KB Output is correct
16 Correct 9 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 8 ms 308 KB Output is correct
20 Correct 12 ms 304 KB Output is correct
21 Correct 7 ms 252 KB Output is correct
22 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 4 ms 300 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 8 ms 208 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
11 Correct 7 ms 208 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 11 ms 208 KB Output is correct
14 Correct 9 ms 208 KB Output is correct
15 Correct 7 ms 208 KB Output is correct
16 Correct 9 ms 208 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 8 ms 308 KB Output is correct
20 Correct 12 ms 304 KB Output is correct
21 Correct 7 ms 252 KB Output is correct
22 Correct 11 ms 208 KB Output is correct
23 Correct 17 ms 340 KB Output is correct
24 Correct 57 ms 456 KB Output is correct
25 Correct 34 ms 336 KB Output is correct
26 Correct 60 ms 336 KB Output is correct
27 Correct 11 ms 336 KB Output is correct
28 Correct 44 ms 336 KB Output is correct
29 Correct 43 ms 340 KB Output is correct
30 Correct 59 ms 340 KB Output is correct
31 Correct 27 ms 452 KB Output is correct
32 Correct 39 ms 328 KB Output is correct
33 Correct 35 ms 324 KB Output is correct
34 Correct 35 ms 340 KB Output is correct
35 Correct 41 ms 336 KB Output is correct
36 Correct 51 ms 324 KB Output is correct
37 Correct 52 ms 336 KB Output is correct
38 Correct 79 ms 336 KB Output is correct
39 Correct 67 ms 344 KB Output is correct
40 Correct 65 ms 340 KB Output is correct
41 Correct 65 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 252 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 29 ms 368 KB Output is correct
8 Partially correct 182 ms 388 KB Output is partially correct
9 Partially correct 66 ms 496 KB Output is partially correct
10 Partially correct 98 ms 348 KB Output is partially correct
11 Partially correct 28 ms 336 KB Output is partially correct
12 Partially correct 60 ms 392 KB Output is partially correct
13 Partially correct 57 ms 400 KB Output is partially correct
14 Partially correct 127 ms 400 KB Output is partially correct
15 Partially correct 41 ms 336 KB Output is partially correct
16 Partially correct 68 ms 576 KB Output is partially correct
17 Partially correct 79 ms 520 KB Output is partially correct
18 Partially correct 85 ms 456 KB Output is partially correct
19 Partially correct 90 ms 396 KB Output is partially correct
20 Partially correct 99 ms 500 KB Output is partially correct
21 Partially correct 121 ms 396 KB Output is partially correct
22 Partially correct 116 ms 396 KB Output is partially correct
23 Partially correct 118 ms 392 KB Output is partially correct
24 Partially correct 131 ms 396 KB Output is partially correct
25 Partially correct 160 ms 516 KB Output is partially correct
26 Partially correct 111 ms 488 KB Output is partially correct
27 Partially correct 122 ms 328 KB Output is partially correct
28 Partially correct 118 ms 392 KB Output is partially correct
29 Partially correct 89 ms 400 KB Output is partially correct
30 Partially correct 98 ms 396 KB Output is partially correct
31 Partially correct 98 ms 428 KB Output is partially correct
32 Partially correct 119 ms 496 KB Output is partially correct
33 Partially correct 143 ms 396 KB Output is partially correct
34 Partially correct 160 ms 516 KB Output is partially correct
35 Partially correct 122 ms 392 KB Output is partially correct
36 Partially correct 130 ms 400 KB Output is partially correct
37 Partially correct 118 ms 504 KB Output is partially correct
38 Partially correct 116 ms 404 KB Output is partially correct
39 Partially correct 119 ms 508 KB Output is partially correct
40 Partially correct 134 ms 408 KB Output is partially correct
41 Partially correct 110 ms 396 KB Output is partially correct
42 Partially correct 109 ms 604 KB Output is partially correct
43 Partially correct 20 ms 208 KB Output is partially correct
44 Partially correct 47 ms 336 KB Output is partially correct
45 Correct 23 ms 464 KB Output is correct
46 Partially correct 94 ms 504 KB Output is partially correct
47 Partially correct 94 ms 392 KB Output is partially correct
48 Partially correct 120 ms 424 KB Output is partially correct