#include<bits/stdc++.h>
#include "insects.h"
//#include "grader.cpp"
using namespace std;
int i,j,p,q,n,m,k,cnt,mx,ans,br,mi,mo,pb;
int cur_size,distinct;
vector <int> st;
vector <int> a,b;
int used[2006];
void add(int cur_size)
{
bool fl = false;
for(auto i:a)
{
if(fl)
{
b.push_back(i);
continue;
}
move_inside(i);
st.push_back(i);
if(press_button()>cur_size)
{
//cout<<i<<endl;
st.pop_back();
b.push_back(i);
move_outside(i);
}
else br++,used[i] = 1;
if(br==cur_size*distinct)
{
fl = true;
}
}
cnt = cur_size;
}
void rem()
{
for(auto i:st)
{
used[i] = false;
br--;
move_outside(i);
}
}
int min_cardinality(int N)
{
n = N;
cur_size = 1;
j = 1;
for(i=0; i<n; i++)
{
if(used[i]==0)
{
move_inside(i);
if(press_button()>cur_size)
{
//cout<<i<<endl;
move_outside(i);
a.push_back(i);
}
else br++,used[i] = 1;
}
}
distinct = br;
int l,r,mid;
l = 2;
r = n/distinct;
ans = 1;
cnt = cur_size;
while(l<=r)///
{
mid = (l+r)/2;
st.clear();
b.clear();
if(mid>cnt)
{
add(mid);
}
// cout<<mid<<" "<<br<<endl;
if(br==mid*distinct)
{
l = mid+1;
ans = mid;
a = b;
cnt = mid;
}
else
{
a = st;
rem();
r = mid-1;
cnt = ans;
}
}
return ans;
}
/*
*/
# |
결과 |
실행 시간 |
메모리 |
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 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
304 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 |
5 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 |
5 ms |
300 KB |
Output is correct |
14 |
Correct |
5 ms |
304 KB |
Output is correct |
15 |
Correct |
4 ms |
208 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
2 ms |
208 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 |
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 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
304 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 |
5 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 |
5 ms |
300 KB |
Output is correct |
14 |
Correct |
5 ms |
304 KB |
Output is correct |
15 |
Correct |
4 ms |
208 KB |
Output is correct |
16 |
Correct |
3 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
208 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
2 ms |
208 KB |
Output is correct |
21 |
Correct |
3 ms |
208 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
18 ms |
208 KB |
Output is correct |
24 |
Correct |
8 ms |
304 KB |
Output is correct |
25 |
Correct |
15 ms |
308 KB |
Output is correct |
26 |
Correct |
13 ms |
308 KB |
Output is correct |
27 |
Correct |
20 ms |
308 KB |
Output is correct |
28 |
Correct |
8 ms |
208 KB |
Output is correct |
29 |
Correct |
18 ms |
208 KB |
Output is correct |
30 |
Correct |
23 ms |
312 KB |
Output is correct |
31 |
Correct |
8 ms |
312 KB |
Output is correct |
32 |
Correct |
18 ms |
300 KB |
Output is correct |
33 |
Correct |
18 ms |
208 KB |
Output is correct |
34 |
Correct |
16 ms |
304 KB |
Output is correct |
35 |
Correct |
15 ms |
292 KB |
Output is correct |
36 |
Correct |
19 ms |
300 KB |
Output is correct |
37 |
Correct |
24 ms |
336 KB |
Output is correct |
38 |
Correct |
22 ms |
208 KB |
Output is correct |
39 |
Correct |
17 ms |
304 KB |
Output is correct |
40 |
Correct |
10 ms |
208 KB |
Output is correct |
41 |
Correct |
8 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
32 ms |
432 KB |
Output is correct |
8 |
Correct |
7 ms |
208 KB |
Output is correct |
9 |
Correct |
31 ms |
296 KB |
Output is correct |
10 |
Correct |
34 ms |
300 KB |
Output is correct |
11 |
Correct |
46 ms |
348 KB |
Output is correct |
12 |
Correct |
25 ms |
208 KB |
Output is correct |
13 |
Correct |
28 ms |
320 KB |
Output is correct |
14 |
Correct |
44 ms |
312 KB |
Output is correct |
15 |
Correct |
37 ms |
304 KB |
Output is correct |
16 |
Correct |
29 ms |
308 KB |
Output is correct |
17 |
Correct |
35 ms |
304 KB |
Output is correct |
18 |
Correct |
37 ms |
208 KB |
Output is correct |
19 |
Correct |
35 ms |
460 KB |
Output is correct |
20 |
Correct |
42 ms |
308 KB |
Output is correct |
21 |
Correct |
37 ms |
312 KB |
Output is correct |
22 |
Correct |
51 ms |
208 KB |
Output is correct |
23 |
Correct |
32 ms |
312 KB |
Output is correct |
24 |
Correct |
37 ms |
304 KB |
Output is correct |
25 |
Correct |
17 ms |
304 KB |
Output is correct |
26 |
Correct |
15 ms |
304 KB |
Output is correct |
27 |
Correct |
33 ms |
304 KB |
Output is correct |
28 |
Correct |
33 ms |
328 KB |
Output is correct |
29 |
Correct |
29 ms |
332 KB |
Output is correct |
30 |
Correct |
48 ms |
208 KB |
Output is correct |
31 |
Correct |
37 ms |
312 KB |
Output is correct |
32 |
Correct |
48 ms |
300 KB |
Output is correct |
33 |
Correct |
25 ms |
312 KB |
Output is correct |
34 |
Correct |
21 ms |
336 KB |
Output is correct |
35 |
Partially correct |
41 ms |
292 KB |
Output is partially correct |
36 |
Correct |
38 ms |
300 KB |
Output is correct |
37 |
Correct |
49 ms |
304 KB |
Output is correct |
38 |
Correct |
46 ms |
300 KB |
Output is correct |
39 |
Correct |
41 ms |
304 KB |
Output is correct |
40 |
Correct |
24 ms |
308 KB |
Output is correct |
41 |
Correct |
33 ms |
300 KB |
Output is correct |
42 |
Partially correct |
50 ms |
300 KB |
Output is partially correct |
43 |
Correct |
10 ms |
208 KB |
Output is correct |
44 |
Correct |
26 ms |
308 KB |
Output is correct |
45 |
Correct |
14 ms |
432 KB |
Output is correct |
46 |
Correct |
19 ms |
312 KB |
Output is correct |
47 |
Correct |
24 ms |
304 KB |
Output is correct |
48 |
Correct |
22 ms |
292 KB |
Output is correct |