답안 #658625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658625 2022-11-13T21:50:24 Z pere_gil 드문 곤충 (IOI22_insects) C++17
100 / 100
57 ms 424 KB
#include "insects.h"
#include "bits/stdc++.h"
using namespace std;
         
int min_cardinality(int n) {
	vector<int> in,out;
	for(int i=0;i<n;i++){
		move_inside(i);
		if(press_button()>1){
			move_outside(i);
			out.push_back(i);
		}
		else in.push_back(i);
	}
	int dif=(int)in.size();

	if(dif==1) return n;
	
	int l=1,r=n/dif+1;
	while(l+1<r){
		int med=(l+r)/2;
		vector<int> new_in,new_out;
		
		while(out.size()){
			int u=out[out.size()-1];
			out.pop_back();
			
			move_inside(u);
			int q=press_button();
			if(q>med){
				move_outside(u);
				new_out.push_back(u);
			}
			else new_in.push_back(u);

			if(in.size()+new_in.size()==dif*med) break;
		}

		if(in.size()+new_in.size()==dif*med){
			for(int i: new_in) in.push_back(i);
			for(int i: new_out) out.push_back(i);
			l=med;
		}
		else{
			for(int i: new_in){
				move_outside(i);
				out.push_back(i);
			}
			r=med;
		}
		
	}
	
	return l;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:36:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |    if(in.size()+new_in.size()==dif*med) break;
      |       ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
insects.cpp:39:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |   if(in.size()+new_in.size()==dif*med){
      |      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 2 ms 208 KB Output is correct
7 Correct 3 ms 304 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 208 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 6 ms 304 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 6 ms 300 KB Output is correct
15 Correct 5 ms 304 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 6 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 5 ms 300 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 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 2 ms 208 KB Output is correct
7 Correct 3 ms 304 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 208 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 6 ms 304 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 6 ms 300 KB Output is correct
15 Correct 5 ms 304 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 6 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 5 ms 300 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 8 ms 304 KB Output is correct
24 Correct 8 ms 208 KB Output is correct
25 Correct 17 ms 300 KB Output is correct
26 Correct 30 ms 208 KB Output is correct
27 Correct 23 ms 208 KB Output is correct
28 Correct 10 ms 308 KB Output is correct
29 Correct 27 ms 304 KB Output is correct
30 Correct 31 ms 288 KB Output is correct
31 Correct 9 ms 208 KB Output is correct
32 Correct 19 ms 308 KB Output is correct
33 Correct 20 ms 328 KB Output is correct
34 Correct 23 ms 304 KB Output is correct
35 Correct 25 ms 336 KB Output is correct
36 Correct 22 ms 304 KB Output is correct
37 Correct 21 ms 208 KB Output is correct
38 Correct 16 ms 208 KB Output is correct
39 Correct 16 ms 208 KB Output is correct
40 Correct 11 ms 304 KB Output is correct
41 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
8 Correct 16 ms 304 KB Output is correct
9 Correct 46 ms 304 KB Output is correct
10 Correct 45 ms 304 KB Output is correct
11 Correct 42 ms 296 KB Output is correct
12 Correct 30 ms 296 KB Output is correct
13 Correct 44 ms 308 KB Output is correct
14 Correct 44 ms 304 KB Output is correct
15 Correct 19 ms 304 KB Output is correct
16 Correct 43 ms 424 KB Output is correct
17 Correct 35 ms 300 KB Output is correct
18 Correct 36 ms 340 KB Output is correct
19 Correct 34 ms 304 KB Output is correct
20 Correct 46 ms 300 KB Output is correct
21 Correct 57 ms 328 KB Output is correct
22 Correct 23 ms 304 KB Output is correct
23 Correct 43 ms 304 KB Output is correct
24 Correct 49 ms 336 KB Output is correct
25 Correct 25 ms 308 KB Output is correct
26 Correct 16 ms 300 KB Output is correct
27 Correct 40 ms 312 KB Output is correct
28 Correct 41 ms 304 KB Output is correct
29 Correct 35 ms 296 KB Output is correct
30 Correct 32 ms 304 KB Output is correct
31 Correct 52 ms 328 KB Output is correct
32 Correct 47 ms 304 KB Output is correct
33 Correct 49 ms 300 KB Output is correct
34 Correct 41 ms 416 KB Output is correct
35 Correct 40 ms 296 KB Output is correct
36 Correct 35 ms 424 KB Output is correct
37 Correct 46 ms 416 KB Output is correct
38 Correct 34 ms 424 KB Output is correct
39 Correct 38 ms 300 KB Output is correct
40 Correct 41 ms 292 KB Output is correct
41 Correct 39 ms 308 KB Output is correct
42 Correct 36 ms 300 KB Output is correct
43 Correct 10 ms 308 KB Output is correct
44 Correct 39 ms 304 KB Output is correct
45 Correct 37 ms 292 KB Output is correct
46 Correct 26 ms 300 KB Output is correct
47 Correct 24 ms 288 KB Output is correct
48 Correct 21 ms 288 KB Output is correct