Submission #830531

# Submission time Handle Problem Language Result Execution time Memory
830531 2023-08-19T07:46:24 Z FatihSolak Rarest Insects (IOI22_insects) C++17
25 / 100
257 ms 328 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N){
	vector<int> v;
	int now = 0;
	int dif = 0;
	auto add = [&](int x){
		v.push_back(x);
		move_inside(x);
		now = press_button();
	};
	auto del = [&](){
		move_outside(v.back());
		v.pop_back();
		now = press_button();
	};
	add(0);
	dif = 1;
	for(int i = 1;i<N;i++){
		add(i);
		if(now == 2){
			del();
		}
		else dif++;
	}
	int last = 1;
	int l = 1,r = N/dif;
	while(l < r){
		int m = (l + r + 1)/2;
		while(v.size())
			del();
		for(int i = 0;i<N;i++){
			if(find(v.begin(),v.end(),i) == v.end()){
				add(i);
				if(now > m)
					del();
			}
		}
		// if(last < m){
		// 	for(int i = 0;i<N;i++){
		// 		if(find(v.begin(),v.end(),i) == v.end()){
		// 			add(i);
		// 			if(now > m)
		// 				del();
		// 		}
		// 	}
		// }
		// if(last > m){
		// 	vector<int> tmp;
		// 	while(now != m){
		// 		tmp.push_back(v.back());
		// 		del();
		// 	}
		// 	for(int i = 0;i<N;i++){
		// 		if(find(tmp.begin(),tmp.end(),i) == tmp.end() && find(v.begin(),v.end(),i) == v.end()){
		// 			add(i);
		// 			if(now > m)
		// 				del();
		// 		}
		// 	}
		// }
		last = m;
		if(v.size() == m * dif){
			l  = m;
		}
		else r = m -1;
	}
	return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:65:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |   if(v.size() == m * dif){
      |      ~~~~~~~~~^~~~~~~~~~
insects.cpp:28:6: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   28 |  int last = 1;
      |      ^~~~
# 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 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 28 ms 296 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
9 Correct 17 ms 208 KB Output is correct
10 Correct 16 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 16 ms 208 KB Output is correct
13 Correct 13 ms 208 KB Output is correct
14 Correct 13 ms 208 KB Output is correct
15 Correct 19 ms 300 KB Output is correct
16 Correct 15 ms 208 KB Output is correct
17 Correct 14 ms 208 KB Output is correct
18 Correct 9 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 10 ms 304 KB Output is correct
21 Correct 4 ms 296 KB Output is correct
22 Correct 3 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 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 28 ms 296 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 11 ms 208 KB Output is correct
9 Correct 17 ms 208 KB Output is correct
10 Correct 16 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 16 ms 208 KB Output is correct
13 Correct 13 ms 208 KB Output is correct
14 Correct 13 ms 208 KB Output is correct
15 Correct 19 ms 300 KB Output is correct
16 Correct 15 ms 208 KB Output is correct
17 Correct 14 ms 208 KB Output is correct
18 Correct 9 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 10 ms 304 KB Output is correct
21 Correct 4 ms 296 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 128 ms 208 KB Output is correct
24 Correct 4 ms 296 KB Output is correct
25 Correct 77 ms 284 KB Output is correct
26 Correct 59 ms 284 KB Output is correct
27 Correct 141 ms 284 KB Output is correct
28 Correct 15 ms 300 KB Output is correct
29 Correct 154 ms 280 KB Output is correct
30 Correct 47 ms 208 KB Output is correct
31 Correct 93 ms 208 KB Output is correct
32 Correct 79 ms 208 KB Output is correct
33 Correct 104 ms 284 KB Output is correct
34 Correct 103 ms 284 KB Output is correct
35 Correct 80 ms 208 KB Output is correct
36 Correct 107 ms 284 KB Output is correct
37 Correct 63 ms 208 KB Output is correct
38 Correct 67 ms 208 KB Output is correct
39 Correct 39 ms 300 KB Output is correct
40 Correct 20 ms 328 KB Output is correct
41 Correct 13 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 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Partially correct 0 ms 208 KB Output is partially correct
6 Partially correct 1 ms 208 KB Output is partially correct
7 Incorrect 257 ms 280 KB Too many queries.
8 Halted 0 ms 0 KB -