#include "insects.h"
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
constexpr ll mod = 1'000'002'022;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define ln "\n"
int min_cardinality(int N) {
vi distinct;
rep(i,0,N){
move_inside(i);
if(press_button() == 1) distinct.pb(i);
else move_outside(i);
}
for(auto el: distinct) move_outside(el);
std::set<ll> inside, outside;
rep(i,0,N) outside.insert(i);
ll left = 0, right = N/distinct.size()+1;
ll packed = 0;
while(left+1 < right){
ll mid = (left+right)/2;
{
vi rm;
for(auto el: outside){
move_inside(el);
if(press_button() > mid) move_outside(el);
else{
packed++;
inside.insert(el);
rm.pb(el);
}
}
for(auto el: rm) outside.erase(el);
if(mid*distinct.size() == packed){
inside.clear();
left = mid;
}
else{
right = mid;
outside.clear();
for(auto el: inside) move_outside(el), packed--;
outside = inside;
inside.clear();
}
}
}
return left;
}
Compilation message
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:49:30: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
49 | if(mid*distinct.size() == packed){
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
5 ms |
300 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
300 KB |
Output is correct |
10 |
Correct |
2 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 |
4 ms |
304 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
4 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
300 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
308 KB |
Output is correct |
22 |
Correct |
4 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 |
5 ms |
300 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
4 ms |
300 KB |
Output is correct |
10 |
Correct |
2 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 |
4 ms |
304 KB |
Output is correct |
14 |
Correct |
5 ms |
208 KB |
Output is correct |
15 |
Correct |
4 ms |
208 KB |
Output is correct |
16 |
Correct |
6 ms |
208 KB |
Output is correct |
17 |
Correct |
5 ms |
300 KB |
Output is correct |
18 |
Correct |
4 ms |
208 KB |
Output is correct |
19 |
Correct |
5 ms |
208 KB |
Output is correct |
20 |
Correct |
4 ms |
208 KB |
Output is correct |
21 |
Correct |
5 ms |
308 KB |
Output is correct |
22 |
Correct |
4 ms |
208 KB |
Output is correct |
23 |
Correct |
25 ms |
300 KB |
Output is correct |
24 |
Correct |
12 ms |
336 KB |
Output is correct |
25 |
Correct |
18 ms |
280 KB |
Output is correct |
26 |
Correct |
24 ms |
292 KB |
Output is correct |
27 |
Correct |
20 ms |
328 KB |
Output is correct |
28 |
Correct |
12 ms |
332 KB |
Output is correct |
29 |
Correct |
22 ms |
296 KB |
Output is correct |
30 |
Correct |
16 ms |
296 KB |
Output is correct |
31 |
Correct |
20 ms |
296 KB |
Output is correct |
32 |
Correct |
26 ms |
336 KB |
Output is correct |
33 |
Correct |
21 ms |
288 KB |
Output is correct |
34 |
Correct |
20 ms |
344 KB |
Output is correct |
35 |
Correct |
20 ms |
336 KB |
Output is correct |
36 |
Correct |
15 ms |
352 KB |
Output is correct |
37 |
Correct |
24 ms |
276 KB |
Output is correct |
38 |
Correct |
19 ms |
336 KB |
Output is correct |
39 |
Correct |
23 ms |
300 KB |
Output is correct |
40 |
Correct |
15 ms |
336 KB |
Output is correct |
41 |
Correct |
18 ms |
356 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 |
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 |
43 ms |
404 KB |
Output is correct |
8 |
Correct |
37 ms |
428 KB |
Output is correct |
9 |
Correct |
38 ms |
416 KB |
Output is correct |
10 |
Correct |
45 ms |
420 KB |
Output is correct |
11 |
Correct |
28 ms |
456 KB |
Output is correct |
12 |
Correct |
42 ms |
408 KB |
Output is correct |
13 |
Correct |
44 ms |
408 KB |
Output is correct |
14 |
Correct |
49 ms |
420 KB |
Output is correct |
15 |
Correct |
49 ms |
416 KB |
Output is correct |
16 |
Correct |
22 ms |
416 KB |
Output is correct |
17 |
Correct |
36 ms |
328 KB |
Output is correct |
18 |
Correct |
43 ms |
404 KB |
Output is correct |
19 |
Partially correct |
40 ms |
328 KB |
Output is partially correct |
20 |
Correct |
49 ms |
420 KB |
Output is correct |
21 |
Correct |
47 ms |
432 KB |
Output is correct |
22 |
Correct |
47 ms |
428 KB |
Output is correct |
23 |
Correct |
36 ms |
328 KB |
Output is correct |
24 |
Correct |
35 ms |
400 KB |
Output is correct |
25 |
Correct |
30 ms |
420 KB |
Output is correct |
26 |
Correct |
33 ms |
448 KB |
Output is correct |
27 |
Partially correct |
49 ms |
420 KB |
Output is partially correct |
28 |
Partially correct |
44 ms |
384 KB |
Output is partially correct |
29 |
Partially correct |
37 ms |
400 KB |
Output is partially correct |
30 |
Partially correct |
32 ms |
380 KB |
Output is partially correct |
31 |
Correct |
37 ms |
420 KB |
Output is correct |
32 |
Correct |
39 ms |
416 KB |
Output is correct |
33 |
Correct |
48 ms |
420 KB |
Output is correct |
34 |
Correct |
47 ms |
408 KB |
Output is correct |
35 |
Partially correct |
48 ms |
392 KB |
Output is partially correct |
36 |
Partially correct |
43 ms |
412 KB |
Output is partially correct |
37 |
Correct |
37 ms |
408 KB |
Output is correct |
38 |
Correct |
36 ms |
416 KB |
Output is correct |
39 |
Partially correct |
53 ms |
408 KB |
Output is partially correct |
40 |
Partially correct |
36 ms |
416 KB |
Output is partially correct |
41 |
Partially correct |
35 ms |
376 KB |
Output is partially correct |
42 |
Partially correct |
53 ms |
408 KB |
Output is partially correct |
43 |
Correct |
8 ms |
300 KB |
Output is correct |
44 |
Correct |
37 ms |
292 KB |
Output is correct |
45 |
Correct |
40 ms |
408 KB |
Output is correct |
46 |
Correct |
44 ms |
380 KB |
Output is correct |
47 |
Correct |
33 ms |
396 KB |
Output is correct |
48 |
Correct |
28 ms |
416 KB |
Output is correct |