답안 #635607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635607 2022-08-26T13:45:25 Z l_reho 드문 곤충 (IOI22_insects) C++17
47.5 / 100
250 ms 592 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

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

int min_cardinality(int N) {
	int low = 1;
	int high = N;
	int nG = 0;
	
	map<int, bool> isIn;
	for(int i = 0; i < N; i++){
		move_inside(i);
		isIn[i] = true;
		int ret = press_button();
		if(ret == 2){
			isIn[i] = false;
			move_outside(i);
		}else 
			nG++;
	}

	for(int i = 0; i < N; i++) if(isIn[i]) {move_outside(i); isIn[i]=false;}

	while(low <= high){
		int mid = low + (high-low)/2;
		// man mano che arrivo al borderline (mid) mi salvo qualcosa, l'ultimo inserito
		// e conto il numero di borderline
		
		// se il numero di borderline è uguale al numero di gruppi, allora
		// o la risposta è mid, oppure tutti questi superano il borderline
		// altrimenti scendo mid
		int cnt = 0, cnt1 = 0;
		
		for(int i = 0; i < N; i++){
			move_inside(i);
			isIn[i] = true;	
			int ret = press_button();
			if(ret == mid) cnt++;
			if(ret == mid+1){
				isIn[i] = false;
				move_outside(i);
				cnt1++;
			}
		}
		
	
		// cout<<"DEBUG-->"<<mid<<" "<<(N-cnt1)<<" "<<cnt1<<endl;
		
		if(cnt1 + mid * nG == N) low = mid+1;
		else high = mid-1;
		 
		// devo cacciare quelli rimasti
		
		for(int i = 0; i < N; i++) if(isIn[i]) {move_outside(i); isIn[i]=false;}
		
	}

	return low-1;
}

# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
6 Correct 14 ms 208 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
8 Correct 13 ms 208 KB Output is correct
9 Correct 19 ms 208 KB Output is correct
10 Correct 24 ms 308 KB Output is correct
11 Correct 19 ms 208 KB Output is correct
12 Correct 16 ms 284 KB Output is correct
13 Correct 19 ms 208 KB Output is correct
14 Correct 19 ms 208 KB Output is correct
15 Correct 15 ms 208 KB Output is correct
16 Correct 16 ms 304 KB Output is correct
17 Correct 19 ms 208 KB Output is correct
18 Correct 18 ms 300 KB Output is correct
19 Correct 15 ms 208 KB Output is correct
20 Correct 20 ms 208 KB Output is correct
21 Correct 14 ms 208 KB Output is correct
22 Correct 14 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
6 Correct 14 ms 208 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
8 Correct 13 ms 208 KB Output is correct
9 Correct 19 ms 208 KB Output is correct
10 Correct 24 ms 308 KB Output is correct
11 Correct 19 ms 208 KB Output is correct
12 Correct 16 ms 284 KB Output is correct
13 Correct 19 ms 208 KB Output is correct
14 Correct 19 ms 208 KB Output is correct
15 Correct 15 ms 208 KB Output is correct
16 Correct 16 ms 304 KB Output is correct
17 Correct 19 ms 208 KB Output is correct
18 Correct 18 ms 300 KB Output is correct
19 Correct 15 ms 208 KB Output is correct
20 Correct 20 ms 208 KB Output is correct
21 Correct 14 ms 208 KB Output is correct
22 Correct 14 ms 208 KB Output is correct
23 Correct 82 ms 308 KB Output is correct
24 Correct 101 ms 300 KB Output is correct
25 Correct 48 ms 336 KB Output is correct
26 Correct 108 ms 336 KB Output is correct
27 Correct 84 ms 336 KB Output is correct
28 Correct 96 ms 336 KB Output is correct
29 Correct 110 ms 320 KB Output is correct
30 Correct 82 ms 308 KB Output is correct
31 Correct 94 ms 336 KB Output is correct
32 Correct 97 ms 356 KB Output is correct
33 Correct 115 ms 324 KB Output is correct
34 Correct 100 ms 312 KB Output is correct
35 Correct 89 ms 320 KB Output is correct
36 Correct 106 ms 324 KB Output is correct
37 Correct 109 ms 336 KB Output is correct
38 Correct 85 ms 360 KB Output is correct
39 Correct 115 ms 332 KB Output is correct
40 Correct 91 ms 324 KB Output is correct
41 Correct 98 ms 308 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 0 ms 208 KB Output is correct
4 Correct 1 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 Partially correct 197 ms 480 KB Output is partially correct
8 Partially correct 194 ms 372 KB Output is partially correct
9 Partially correct 164 ms 388 KB Output is partially correct
10 Partially correct 153 ms 372 KB Output is partially correct
11 Partially correct 238 ms 328 KB Output is partially correct
12 Partially correct 148 ms 500 KB Output is partially correct
13 Partially correct 144 ms 320 KB Output is partially correct
14 Partially correct 246 ms 372 KB Output is partially correct
15 Partially correct 197 ms 496 KB Output is partially correct
16 Partially correct 146 ms 492 KB Output is partially correct
17 Partially correct 243 ms 372 KB Output is partially correct
18 Partially correct 195 ms 368 KB Output is partially correct
19 Partially correct 166 ms 492 KB Output is partially correct
20 Partially correct 176 ms 380 KB Output is partially correct
21 Partially correct 186 ms 592 KB Output is partially correct
22 Partially correct 223 ms 368 KB Output is partially correct
23 Partially correct 118 ms 368 KB Output is partially correct
24 Partially correct 169 ms 484 KB Output is partially correct
25 Partially correct 132 ms 440 KB Output is partially correct
26 Partially correct 148 ms 376 KB Output is partially correct
27 Partially correct 221 ms 444 KB Output is partially correct
28 Partially correct 192 ms 368 KB Output is partially correct
29 Partially correct 164 ms 504 KB Output is partially correct
30 Partially correct 201 ms 376 KB Output is partially correct
31 Partially correct 204 ms 488 KB Output is partially correct
32 Partially correct 169 ms 504 KB Output is partially correct
33 Partially correct 237 ms 372 KB Output is partially correct
34 Partially correct 212 ms 424 KB Output is partially correct
35 Partially correct 224 ms 372 KB Output is partially correct
36 Partially correct 180 ms 372 KB Output is partially correct
37 Partially correct 190 ms 420 KB Output is partially correct
38 Partially correct 164 ms 420 KB Output is partially correct
39 Partially correct 215 ms 376 KB Output is partially correct
40 Partially correct 152 ms 444 KB Output is partially correct
41 Partially correct 212 ms 500 KB Output is partially correct
42 Partially correct 214 ms 372 KB Output is partially correct
43 Partially correct 31 ms 208 KB Output is partially correct
44 Partially correct 250 ms 432 KB Output is partially correct
45 Partially correct 169 ms 568 KB Output is partially correct
46 Partially correct 215 ms 400 KB Output is partially correct
47 Partially correct 154 ms 448 KB Output is partially correct
48 Partially correct 189 ms 480 KB Output is partially correct