Submission #702671

# Submission time Handle Problem Language Result Execution time Memory
702671 2023-02-24T18:17:08 Z onjo0127 Rarest Insects (IOI22_insects) C++17
100 / 100
81 ms 308 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int in[2009];

int min_cardinality(int N) {
	int c = 0, g = 0;
	for(int i=0; i<N; i++) {
		move_inside(i);
		int x = press_button();
		if(x == 2) move_outside(i);
		else ++g, in[i] = 1;
	}
	c = g;
	int l = 2, r = N/g, p = 1;
	while(l <= r) {
		int m = l+r >> 1;
        if(r-l > 5) ++m;
		if(m < p) for(int j=0; j<N; j++) if(in[j] > m) {
			move_outside(j);
			in[j] = 0;
			--c;
		}
		for(int j=0; j<N; j++) if(!in[j]) {
			move_inside(j);
			int x = press_button();
			if(x == m+1) move_outside(j);
			else ++c, in[j] = m;
		}
		if(g*m != c) {
			r = m-1;
			for(int j=0; j<N; j++) if(!in[j]) in[j] = -1;
		}
		else l = m+1;
		p = m;
	}
	return r;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:18:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |   int m = l+r >> 1;
      |           ~^~
# 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 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 4 ms 208 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 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
9 Correct 6 ms 208 KB Output is correct
10 Correct 3 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 7 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 6 ms 208 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 6 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 4 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 31 ms 284 KB Output is correct
24 Correct 10 ms 208 KB Output is correct
25 Correct 19 ms 208 KB Output is correct
26 Correct 20 ms 208 KB Output is correct
27 Correct 25 ms 208 KB Output is correct
28 Correct 10 ms 308 KB Output is correct
29 Correct 28 ms 300 KB Output is correct
30 Correct 22 ms 208 KB Output is correct
31 Correct 26 ms 208 KB Output is correct
32 Correct 22 ms 208 KB Output is correct
33 Correct 14 ms 208 KB Output is correct
34 Correct 25 ms 284 KB Output is correct
35 Correct 23 ms 208 KB Output is correct
36 Correct 23 ms 284 KB Output is correct
37 Correct 20 ms 208 KB Output is correct
38 Correct 37 ms 208 KB Output is correct
39 Correct 20 ms 220 KB Output is correct
40 Correct 14 ms 308 KB Output is correct
41 Correct 5 ms 308 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 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 81 ms 296 KB Output is correct
8 Correct 21 ms 300 KB Output is correct
9 Correct 45 ms 208 KB Output is correct
10 Correct 55 ms 288 KB Output is correct
11 Correct 43 ms 284 KB Output is correct
12 Correct 12 ms 300 KB Output is correct
13 Correct 38 ms 208 KB Output is correct
14 Correct 58 ms 208 KB Output is correct
15 Correct 42 ms 280 KB Output is correct
16 Correct 40 ms 208 KB Output is correct
17 Correct 25 ms 208 KB Output is correct
18 Correct 39 ms 280 KB Output is correct
19 Correct 42 ms 284 KB Output is correct
20 Correct 38 ms 208 KB Output is correct
21 Correct 48 ms 292 KB Output is correct
22 Correct 54 ms 296 KB Output is correct
23 Correct 50 ms 208 KB Output is correct
24 Correct 42 ms 304 KB Output is correct
25 Correct 23 ms 304 KB Output is correct
26 Correct 13 ms 300 KB Output is correct
27 Correct 37 ms 208 KB Output is correct
28 Correct 57 ms 280 KB Output is correct
29 Correct 47 ms 208 KB Output is correct
30 Correct 54 ms 208 KB Output is correct
31 Correct 47 ms 208 KB Output is correct
32 Correct 41 ms 292 KB Output is correct
33 Correct 23 ms 284 KB Output is correct
34 Correct 69 ms 288 KB Output is correct
35 Correct 56 ms 284 KB Output is correct
36 Correct 23 ms 284 KB Output is correct
37 Correct 42 ms 280 KB Output is correct
38 Correct 59 ms 208 KB Output is correct
39 Correct 26 ms 288 KB Output is correct
40 Correct 43 ms 280 KB Output is correct
41 Correct 45 ms 288 KB Output is correct
42 Correct 54 ms 212 KB Output is correct
43 Correct 12 ms 208 KB Output is correct
44 Correct 35 ms 304 KB Output is correct
45 Correct 55 ms 280 KB Output is correct
46 Correct 33 ms 208 KB Output is correct
47 Correct 24 ms 208 KB Output is correct
48 Correct 31 ms 300 KB Output is correct