Submission #863882

# Submission time Handle Problem Language Result Execution time Memory
863882 2023-10-21T10:19:43 Z ThylOne Rarest Insects (IOI22_insects) C++17
57.75 / 100
79 ms 1624 KB
//#define LOCAL
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;
#define pb push_back
vector<int> representant;
vector<int> chef;

void solve(vector<int> inconnus,int inf,int sup){
	#ifdef LOCAL
	cout<<inf<<' '<<sup<<endl;
	for(int v:inconnus){
		cout<<v<<' ';
	}cout<<endl;
	#endif
	if(inf==sup){
		//feuilles
		for(int i:inconnus){
			chef[i] = representant[inf];
		}
		return;
	}else{
		int mid=(inf+sup)/2;
		for(int i=inf;i<=mid;i++)move_inside(representant[i]);
		vector<int> listLeft,listRight;
		for(int Inc:inconnus){
			move_inside(Inc);
			if(press_button()==2){
				listLeft.pb(Inc);
			}else{
				listRight.pb(Inc);
			}
			move_outside(Inc);
		}
		for(int i=inf;i<=mid;i++)move_outside(representant[i]);
		solve(listLeft,inf,mid);
		solve(listRight,mid+1,sup);

	}
}
int min_cardinality(int N) {
	chef.resize(N);
	vector<int> inconnus;
	for(int i=0;i<N;i++){
		move_inside(i);
		if(press_button()>1){
			move_outside(i);
			inconnus.pb(i);
		}else{
			chef[i]=i;
			representant.pb(i);
		}
	}
	for(int i:representant){
		move_outside(i);
	}
	solve(inconnus,0,representant.size()-1);
	map<int,int> mem;
	for(int i=0;i<N;i++){
		mem[chef[i]]++;
	}
	int mini = N+1;
	#ifdef LOCAL
	for(int i=0;i<N;i++){
		cout<<chef[i]<<' ';
	}
	cout<<endl;
	#endif
	for(int i=0;i<N;i++){
		mini = min(mini,mem[chef[i]]);
	}
	
	return mini;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 4 ms 692 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 440 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 4 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 4 ms 856 KB Output is correct
19 Correct 4 ms 600 KB Output is correct
20 Correct 5 ms 600 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 6 ms 856 KB Output is correct
9 Correct 4 ms 692 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 440 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 5 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 4 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 4 ms 856 KB Output is correct
19 Correct 4 ms 600 KB Output is correct
20 Correct 5 ms 600 KB Output is correct
21 Correct 4 ms 344 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
23 Correct 6 ms 856 KB Output is correct
24 Correct 6 ms 700 KB Output is correct
25 Correct 28 ms 704 KB Output is correct
26 Correct 26 ms 928 KB Output is correct
27 Correct 11 ms 892 KB Output is correct
28 Correct 24 ms 1120 KB Output is correct
29 Correct 13 ms 604 KB Output is correct
30 Correct 32 ms 932 KB Output is correct
31 Correct 19 ms 856 KB Output is correct
32 Correct 20 ms 704 KB Output is correct
33 Correct 21 ms 448 KB Output is correct
34 Correct 20 ms 600 KB Output is correct
35 Correct 24 ms 956 KB Output is correct
36 Correct 23 ms 1112 KB Output is correct
37 Correct 27 ms 704 KB Output is correct
38 Correct 39 ms 856 KB Output is correct
39 Correct 28 ms 860 KB Output is correct
40 Correct 27 ms 860 KB Output is correct
41 Correct 20 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 8 ms 856 KB Output is correct
8 Partially correct 14 ms 1100 KB Output is partially correct
9 Partially correct 53 ms 956 KB Output is partially correct
10 Partially correct 55 ms 720 KB Output is partially correct
11 Correct 18 ms 600 KB Output is correct
12 Partially correct 53 ms 1624 KB Output is partially correct
13 Partially correct 32 ms 1204 KB Output is partially correct
14 Partially correct 63 ms 856 KB Output is partially correct
15 Partially correct 33 ms 1216 KB Output is partially correct
16 Partially correct 42 ms 856 KB Output is partially correct
17 Partially correct 42 ms 600 KB Output is partially correct
18 Partially correct 42 ms 876 KB Output is partially correct
19 Partially correct 47 ms 700 KB Output is partially correct
20 Partially correct 49 ms 872 KB Output is partially correct
21 Partially correct 59 ms 1208 KB Output is partially correct
22 Partially correct 70 ms 964 KB Output is partially correct
23 Partially correct 72 ms 1124 KB Output is partially correct
24 Partially correct 61 ms 984 KB Output is partially correct
25 Partially correct 54 ms 840 KB Output is partially correct
26 Partially correct 39 ms 936 KB Output is partially correct
27 Partially correct 63 ms 864 KB Output is partially correct
28 Partially correct 65 ms 1108 KB Output is partially correct
29 Partially correct 55 ms 1112 KB Output is partially correct
30 Partially correct 58 ms 940 KB Output is partially correct
31 Partially correct 62 ms 716 KB Output is partially correct
32 Partially correct 58 ms 1448 KB Output is partially correct
33 Partially correct 64 ms 716 KB Output is partially correct
34 Partially correct 69 ms 852 KB Output is partially correct
35 Partially correct 61 ms 960 KB Output is partially correct
36 Partially correct 60 ms 892 KB Output is partially correct
37 Partially correct 64 ms 1116 KB Output is partially correct
38 Partially correct 58 ms 716 KB Output is partially correct
39 Partially correct 79 ms 876 KB Output is partially correct
40 Partially correct 65 ms 1208 KB Output is partially correct
41 Partially correct 60 ms 1376 KB Output is partially correct
42 Partially correct 56 ms 1200 KB Output is partially correct
43 Partially correct 8 ms 856 KB Output is partially correct
44 Partially correct 39 ms 996 KB Output is partially correct
45 Correct 23 ms 1112 KB Output is correct
46 Partially correct 63 ms 1464 KB Output is partially correct
47 Partially correct 47 ms 1496 KB Output is partially correct
48 Partially correct 57 ms 1360 KB Output is partially correct