#include "insects.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int par[maxn], rnk[maxn];
int used[maxn], diff, n;
vector < int > safe;
bool check(int x)
{
int cnt = safe.size();
vector < int > vec;
for (int i = 0; i < n && cnt != x * diff; i ++)
{
if (!used[i])
continue;
move_inside(i);
vec.push_back(i);
if (press_button() > x)
{
move_outside(i);
vec.pop_back();
}
else
{
cnt ++;
}
}
if (cnt != x * diff)
{
for (int i = 0; i < n; i ++)
used[i] = 0;
for (int v : vec)
used[v] = 1;
for (int v : vec)
move_outside(v);
}
else
{
for (int v : vec)
used[v] = 0, safe.push_back(v);
}
return cnt == x * diff;
}
int find_different(int N)
{
int cnt = 0;
vector < int > vec;
for (int i = 0; i < n; i ++)
{
move_inside(i);
vec.push_back(i);
if (press_button() > 1)
{
move_outside(i);
vec.pop_back();
}
else
{
cnt ++;
}
}
for (int v : vec)
move_outside(v);
return cnt;
}
int min_cardinality(int N)
{
n = N;
diff = find_different(N);
for (int i = 0; i < N; i ++)
used[i] = 1;
int lf = 0, rf = N;
rf = N / diff;
if (diff == 1)
return N;
while(lf <= rf)
{
int mf = (lf + rf) / 2;
if (check(mf))
lf = mf + 1;
else
rf = mf - 1;
}
return rf;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
7 ms |
208 KB |
Output is correct |
15 |
Correct |
10 ms |
304 KB |
Output is correct |
16 |
Correct |
3 ms |
304 KB |
Output is correct |
17 |
Correct |
9 ms |
236 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
13 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
208 KB |
Output is correct |
10 |
Correct |
5 ms |
208 KB |
Output is correct |
11 |
Correct |
4 ms |
208 KB |
Output is correct |
12 |
Correct |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
6 ms |
208 KB |
Output is correct |
14 |
Correct |
7 ms |
208 KB |
Output is correct |
15 |
Correct |
10 ms |
304 KB |
Output is correct |
16 |
Correct |
3 ms |
304 KB |
Output is correct |
17 |
Correct |
9 ms |
236 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
13 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
208 KB |
Output is correct |
22 |
Correct |
4 ms |
208 KB |
Output is correct |
23 |
Correct |
5 ms |
304 KB |
Output is correct |
24 |
Correct |
14 ms |
312 KB |
Output is correct |
25 |
Correct |
45 ms |
292 KB |
Output is correct |
26 |
Correct |
18 ms |
300 KB |
Output is correct |
27 |
Correct |
12 ms |
300 KB |
Output is correct |
28 |
Correct |
31 ms |
292 KB |
Output is correct |
29 |
Correct |
26 ms |
288 KB |
Output is correct |
30 |
Correct |
14 ms |
304 KB |
Output is correct |
31 |
Correct |
24 ms |
280 KB |
Output is correct |
32 |
Correct |
49 ms |
296 KB |
Output is correct |
33 |
Correct |
30 ms |
288 KB |
Output is correct |
34 |
Correct |
22 ms |
296 KB |
Output is correct |
35 |
Correct |
26 ms |
292 KB |
Output is correct |
36 |
Correct |
43 ms |
300 KB |
Output is correct |
37 |
Correct |
48 ms |
292 KB |
Output is correct |
38 |
Correct |
36 ms |
284 KB |
Output is correct |
39 |
Correct |
19 ms |
208 KB |
Output is correct |
40 |
Correct |
21 ms |
288 KB |
Output is correct |
41 |
Correct |
18 ms |
292 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 |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
10 ms |
208 KB |
Output is correct |
8 |
Correct |
46 ms |
304 KB |
Output is correct |
9 |
Correct |
49 ms |
300 KB |
Output is correct |
10 |
Correct |
45 ms |
304 KB |
Output is correct |
11 |
Correct |
57 ms |
280 KB |
Output is correct |
12 |
Correct |
33 ms |
288 KB |
Output is correct |
13 |
Correct |
69 ms |
296 KB |
Output is correct |
14 |
Correct |
47 ms |
284 KB |
Output is correct |
15 |
Correct |
47 ms |
300 KB |
Output is correct |
16 |
Correct |
61 ms |
304 KB |
Output is correct |
17 |
Correct |
29 ms |
304 KB |
Output is correct |
18 |
Correct |
51 ms |
304 KB |
Output is correct |
19 |
Correct |
45 ms |
304 KB |
Output is correct |
20 |
Correct |
27 ms |
296 KB |
Output is correct |
21 |
Correct |
41 ms |
296 KB |
Output is correct |
22 |
Correct |
56 ms |
288 KB |
Output is correct |
23 |
Correct |
74 ms |
208 KB |
Output is correct |
24 |
Correct |
29 ms |
300 KB |
Output is correct |
25 |
Correct |
31 ms |
300 KB |
Output is correct |
26 |
Correct |
38 ms |
300 KB |
Output is correct |
27 |
Correct |
30 ms |
284 KB |
Output is correct |
28 |
Correct |
38 ms |
304 KB |
Output is correct |
29 |
Correct |
40 ms |
292 KB |
Output is correct |
30 |
Partially correct |
75 ms |
304 KB |
Output is partially correct |
31 |
Correct |
32 ms |
296 KB |
Output is correct |
32 |
Correct |
80 ms |
296 KB |
Output is correct |
33 |
Correct |
36 ms |
292 KB |
Output is correct |
34 |
Correct |
45 ms |
296 KB |
Output is correct |
35 |
Correct |
46 ms |
304 KB |
Output is correct |
36 |
Correct |
37 ms |
304 KB |
Output is correct |
37 |
Correct |
30 ms |
328 KB |
Output is correct |
38 |
Correct |
53 ms |
284 KB |
Output is correct |
39 |
Correct |
47 ms |
304 KB |
Output is correct |
40 |
Correct |
42 ms |
300 KB |
Output is correct |
41 |
Correct |
73 ms |
284 KB |
Output is correct |
42 |
Partially correct |
31 ms |
296 KB |
Output is partially correct |
43 |
Correct |
15 ms |
208 KB |
Output is correct |
44 |
Correct |
42 ms |
280 KB |
Output is correct |
45 |
Correct |
40 ms |
288 KB |
Output is correct |
46 |
Correct |
47 ms |
296 KB |
Output is correct |
47 |
Correct |
47 ms |
300 KB |
Output is correct |
48 |
Correct |
78 ms |
300 KB |
Output is correct |