답안 #830526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830526 2023-08-19T07:42:38 Z josanneo22 드문 곤충 (IOI22_insects) C++17
100 / 100
50 ms 428 KB
#include <bits/stdc++.h>
using namespace std;

#define ld long double
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second

/*草,以后一定要拿金牌啊!!! 注意数值范围拿分数哦*/
#include "insects.h"
const int S=1e5+5;
mt19937 rand1(time(0));
int l,r,cnt,cnt1,a[S],n;
bool vs[S],vs1[S];

void ins(int x) {++cnt1;move_inside(x-1);}
void dlt(int x) {--cnt1;move_outside(x-1);}
int qry() {return press_button();}

int min_cardinality(int N) {
	n=N;
	for(int i=1;i<=n;++i) {
		ins(i);
		if(qry()>1) dlt(i);
		else vs[i]=1,++cnt;
	}
	if(cnt==1) return n;
	l=2;r=n/cnt;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		for(int i=1;i<=n;++i) {vs1[i]=0,a[i]=i;}
		shuffle(a+1,a+n+1,rand1);
		for(int i=1;i<=n;++i){
			if(!vs[a[i]])
			{
				if(cnt*mid<=cnt1) break;
				ins(a[i]);
				if(qry()>mid) dlt(a[i]);
				else vs1[a[i]]=1;
			}
		}
		if(cnt*mid<=cnt1) {
			l=mid+1;
			for(int i=1;i<=n;++i) if(vs1[i]) vs[i]=1;
		}
		else {
			r=cnt1/cnt;
			for(int i=1;i<=n;++i) {
				if(vs1[i]) dlt(i);
				else vs[i]=1;
			}
		}
	}
	return r;
}
# 결과 실행 시간 메모리 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 1 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 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 2 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 2 ms 320 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 320 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 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 1 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 3 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 2 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 5 ms 208 KB Output is correct
17 Correct 2 ms 320 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 320 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 7 ms 208 KB Output is correct
24 Correct 8 ms 300 KB Output is correct
25 Correct 19 ms 208 KB Output is correct
26 Correct 14 ms 328 KB Output is correct
27 Correct 14 ms 208 KB Output is correct
28 Correct 8 ms 208 KB Output is correct
29 Correct 23 ms 208 KB Output is correct
30 Correct 31 ms 208 KB Output is correct
31 Correct 15 ms 320 KB Output is correct
32 Correct 17 ms 208 KB Output is correct
33 Correct 21 ms 208 KB Output is correct
34 Correct 11 ms 428 KB Output is correct
35 Correct 17 ms 312 KB Output is correct
36 Correct 21 ms 320 KB Output is correct
37 Correct 19 ms 324 KB Output is correct
38 Correct 20 ms 208 KB Output is correct
39 Correct 18 ms 208 KB Output is correct
40 Correct 12 ms 208 KB Output is correct
41 Correct 9 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 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 17 ms 208 KB Output is correct
8 Correct 14 ms 312 KB Output is correct
9 Correct 47 ms 208 KB Output is correct
10 Correct 50 ms 312 KB Output is correct
11 Correct 40 ms 312 KB Output is correct
12 Correct 26 ms 208 KB Output is correct
13 Correct 27 ms 304 KB Output is correct
14 Correct 33 ms 316 KB Output is correct
15 Correct 31 ms 208 KB Output is correct
16 Correct 32 ms 308 KB Output is correct
17 Correct 36 ms 208 KB Output is correct
18 Correct 32 ms 320 KB Output is correct
19 Correct 29 ms 312 KB Output is correct
20 Correct 43 ms 304 KB Output is correct
21 Correct 35 ms 208 KB Output is correct
22 Correct 47 ms 300 KB Output is correct
23 Correct 45 ms 308 KB Output is correct
24 Correct 38 ms 208 KB Output is correct
25 Correct 26 ms 208 KB Output is correct
26 Correct 17 ms 208 KB Output is correct
27 Correct 33 ms 304 KB Output is correct
28 Correct 29 ms 208 KB Output is correct
29 Correct 38 ms 312 KB Output is correct
30 Correct 36 ms 208 KB Output is correct
31 Correct 29 ms 316 KB Output is correct
32 Correct 37 ms 308 KB Output is correct
33 Correct 37 ms 208 KB Output is correct
34 Correct 31 ms 208 KB Output is correct
35 Correct 34 ms 300 KB Output is correct
36 Correct 36 ms 312 KB Output is correct
37 Correct 45 ms 208 KB Output is correct
38 Correct 38 ms 208 KB Output is correct
39 Correct 42 ms 300 KB Output is correct
40 Correct 36 ms 304 KB Output is correct
41 Correct 44 ms 336 KB Output is correct
42 Correct 29 ms 208 KB Output is correct
43 Correct 8 ms 208 KB Output is correct
44 Correct 29 ms 208 KB Output is correct
45 Correct 32 ms 208 KB Output is correct
46 Correct 22 ms 208 KB Output is correct
47 Correct 17 ms 208 KB Output is correct
48 Correct 25 ms 324 KB Output is correct