#include "insects.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int d;
int min_cardinality(int n) {
vector <int> act;
bool used[n + 1];
fill(used, used + n + 1, false);
for(int i = 0; i < n; i++){
move_inside(i);
int x = press_button();
if(x == 2) move_outside(i);
else act.pb(i);
}
//for(int to : act) cout << to << ' ';
//int l = 0, r = act.size();
for(int to : act) move_outside(to);
int d = act.size();
int l = 1, r = n / d + 1;
vector <int> cur;
while(l + 1 < r){
int mid = (l + r) / 2;
vector <int> vv;
for(int i = 0; i < n; i++){
if(used[i]) continue;
move_inside(i);
int x = press_button();
if(x > mid) move_outside(i);
else vv.pb(i);
if(vv.size() + cur.size() == mid * d) break;
}
int x = cur.size() + vv.size();
if(x == mid * d){
l = mid;
for(int to : vv) used[to] = true, cur.pb(to);
}
else{
r = mid;
for(int i = 0; i < n; i++) used[i] =true;
for(int to : vv) used[to] = false, move_outside(to);
}
}
return l;
}
Compilation message
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:40:33: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | if(vv.size() + cur.size() == mid * d) break;
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
4 ms |
296 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 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 |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
4 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
300 KB |
Output is correct |
21 |
Correct |
4 ms |
300 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 |
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 |
4 ms |
296 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
4 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 |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
208 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
5 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
208 KB |
Output is correct |
17 |
Correct |
4 ms |
208 KB |
Output is correct |
18 |
Correct |
5 ms |
208 KB |
Output is correct |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
300 KB |
Output is correct |
21 |
Correct |
4 ms |
300 KB |
Output is correct |
22 |
Correct |
2 ms |
208 KB |
Output is correct |
23 |
Correct |
18 ms |
296 KB |
Output is correct |
24 |
Correct |
7 ms |
208 KB |
Output is correct |
25 |
Correct |
18 ms |
284 KB |
Output is correct |
26 |
Correct |
18 ms |
208 KB |
Output is correct |
27 |
Correct |
24 ms |
208 KB |
Output is correct |
28 |
Correct |
8 ms |
300 KB |
Output is correct |
29 |
Correct |
25 ms |
208 KB |
Output is correct |
30 |
Correct |
20 ms |
208 KB |
Output is correct |
31 |
Correct |
15 ms |
208 KB |
Output is correct |
32 |
Correct |
11 ms |
300 KB |
Output is correct |
33 |
Correct |
14 ms |
300 KB |
Output is correct |
34 |
Correct |
18 ms |
208 KB |
Output is correct |
35 |
Correct |
15 ms |
300 KB |
Output is correct |
36 |
Correct |
16 ms |
300 KB |
Output is correct |
37 |
Correct |
20 ms |
288 KB |
Output is correct |
38 |
Correct |
16 ms |
300 KB |
Output is correct |
39 |
Correct |
20 ms |
208 KB |
Output is correct |
40 |
Correct |
13 ms |
208 KB |
Output is correct |
41 |
Correct |
7 ms |
300 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 |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
31 ms |
292 KB |
Output is correct |
8 |
Correct |
16 ms |
296 KB |
Output is correct |
9 |
Correct |
29 ms |
288 KB |
Output is correct |
10 |
Correct |
37 ms |
284 KB |
Output is correct |
11 |
Correct |
46 ms |
276 KB |
Output is correct |
12 |
Correct |
27 ms |
296 KB |
Output is correct |
13 |
Correct |
48 ms |
280 KB |
Output is correct |
14 |
Correct |
39 ms |
328 KB |
Output is correct |
15 |
Correct |
16 ms |
292 KB |
Output is correct |
16 |
Correct |
39 ms |
536 KB |
Output is correct |
17 |
Correct |
47 ms |
288 KB |
Output is correct |
18 |
Correct |
18 ms |
300 KB |
Output is correct |
19 |
Correct |
43 ms |
296 KB |
Output is correct |
20 |
Correct |
39 ms |
292 KB |
Output is correct |
21 |
Correct |
40 ms |
292 KB |
Output is correct |
22 |
Partially correct |
54 ms |
288 KB |
Output is partially correct |
23 |
Correct |
41 ms |
288 KB |
Output is correct |
24 |
Correct |
37 ms |
304 KB |
Output is correct |
25 |
Correct |
29 ms |
284 KB |
Output is correct |
26 |
Correct |
13 ms |
300 KB |
Output is correct |
27 |
Correct |
33 ms |
292 KB |
Output is correct |
28 |
Correct |
35 ms |
208 KB |
Output is correct |
29 |
Partially correct |
56 ms |
292 KB |
Output is partially correct |
30 |
Partially correct |
57 ms |
292 KB |
Output is partially correct |
31 |
Correct |
46 ms |
288 KB |
Output is correct |
32 |
Correct |
46 ms |
284 KB |
Output is correct |
33 |
Correct |
53 ms |
284 KB |
Output is correct |
34 |
Correct |
26 ms |
412 KB |
Output is correct |
35 |
Partially correct |
42 ms |
276 KB |
Output is partially correct |
36 |
Correct |
31 ms |
288 KB |
Output is correct |
37 |
Correct |
48 ms |
288 KB |
Output is correct |
38 |
Correct |
48 ms |
328 KB |
Output is correct |
39 |
Correct |
33 ms |
292 KB |
Output is correct |
40 |
Correct |
34 ms |
284 KB |
Output is correct |
41 |
Correct |
44 ms |
280 KB |
Output is correct |
42 |
Partially correct |
38 ms |
296 KB |
Output is partially correct |
43 |
Correct |
12 ms |
208 KB |
Output is correct |
44 |
Correct |
30 ms |
208 KB |
Output is correct |
45 |
Correct |
33 ms |
280 KB |
Output is correct |
46 |
Correct |
27 ms |
284 KB |
Output is correct |
47 |
Correct |
34 ms |
208 KB |
Output is correct |
48 |
Correct |
35 ms |
304 KB |
Output is correct |