Submission #629393

# Submission time Handle Problem Language Result Execution time Memory
629393 2022-08-14T12:49:17 Z kdh9949 Rarest Insects (IOI22_insects) C++17
100 / 100
60 ms 420 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

const int M = 2005;
int chk[M], mst[M], exc[M], cnt;

int IN(int x) {
  if(chk[x]) return 0; 
  chk[x] = 1;
  cnt++;
  move_inside(x);
  return 1;
}

int OUT(int x) {
  if(!chk[x]) return 0;
  chk[x] = 0;
  cnt--;
  move_outside(x);
  return 1;
}

int GET() { return press_button(); }

int min_cardinality(int N) {
  IN(0);
  for(int i = 1; i < N; i++) {
    IN(i);
    if(GET() != 1) OUT(i);
  }
  int K = cnt;
  if(K == 1) return N;
  for(int i = 0; i < N; i++) mst[i] = chk[i];

  int L = 1, R = N / K;
  while(L < R) {
    int M = (L + R) / 2 - (R - L > 5);
    for(int i = 0; i < N; i++) if(!exc[i]) {
      if(IN(i)) if(GET() > M + 1) OUT(i);
      if(cnt == (M + 1) * K) break;
    }
    if(cnt == (M + 1) * K) {
      for(int i = 0; i < N; i++) mst[i] = chk[i];
      L = M + 1;
    }
    else {
      for(int i = 0; i < N; i++) if(!mst[i]) if(!OUT(i)) exc[i] = 1;
      R = M;
    }
  }
  return L;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 5 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 7 ms 308 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 304 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 4 ms 308 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 208 KB Output is correct
10 Correct 5 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 4 ms 332 KB Output is correct
13 Correct 7 ms 208 KB Output is correct
14 Correct 5 ms 208 KB Output is correct
15 Correct 6 ms 208 KB Output is correct
16 Correct 7 ms 308 KB Output is correct
17 Correct 5 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 4 ms 304 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 4 ms 308 KB Output is correct
22 Correct 3 ms 208 KB Output is correct
23 Correct 9 ms 304 KB Output is correct
24 Correct 5 ms 312 KB Output is correct
25 Correct 15 ms 308 KB Output is correct
26 Correct 22 ms 312 KB Output is correct
27 Correct 19 ms 308 KB Output is correct
28 Correct 8 ms 312 KB Output is correct
29 Correct 26 ms 304 KB Output is correct
30 Correct 17 ms 304 KB Output is correct
31 Correct 22 ms 308 KB Output is correct
32 Correct 24 ms 300 KB Output is correct
33 Correct 24 ms 308 KB Output is correct
34 Correct 24 ms 300 KB Output is correct
35 Correct 21 ms 296 KB Output is correct
36 Correct 26 ms 308 KB Output is correct
37 Correct 16 ms 308 KB Output is correct
38 Correct 21 ms 304 KB Output is correct
39 Correct 19 ms 296 KB Output is correct
40 Correct 12 ms 304 KB Output is correct
41 Correct 8 ms 304 KB Output is correct
# Verdict Execution time Memory 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 16 ms 308 KB Output is correct
8 Correct 19 ms 336 KB Output is correct
9 Correct 43 ms 304 KB Output is correct
10 Correct 34 ms 288 KB Output is correct
11 Correct 42 ms 308 KB Output is correct
12 Correct 21 ms 296 KB Output is correct
13 Correct 52 ms 296 KB Output is correct
14 Correct 47 ms 208 KB Output is correct
15 Correct 35 ms 208 KB Output is correct
16 Correct 37 ms 300 KB Output is correct
17 Correct 42 ms 296 KB Output is correct
18 Correct 40 ms 208 KB Output is correct
19 Correct 38 ms 300 KB Output is correct
20 Correct 30 ms 208 KB Output is correct
21 Correct 41 ms 288 KB Output is correct
22 Correct 55 ms 308 KB Output is correct
23 Correct 50 ms 208 KB Output is correct
24 Correct 31 ms 300 KB Output is correct
25 Correct 15 ms 416 KB Output is correct
26 Correct 16 ms 208 KB Output is correct
27 Correct 32 ms 208 KB Output is correct
28 Correct 29 ms 208 KB Output is correct
29 Correct 42 ms 304 KB Output is correct
30 Correct 45 ms 208 KB Output is correct
31 Correct 50 ms 324 KB Output is correct
32 Correct 55 ms 292 KB Output is correct
33 Correct 46 ms 420 KB Output is correct
34 Correct 56 ms 300 KB Output is correct
35 Correct 58 ms 208 KB Output is correct
36 Correct 20 ms 308 KB Output is correct
37 Correct 44 ms 364 KB Output is correct
38 Correct 60 ms 300 KB Output is correct
39 Correct 46 ms 208 KB Output is correct
40 Correct 22 ms 328 KB Output is correct
41 Correct 42 ms 312 KB Output is correct
42 Correct 46 ms 296 KB Output is correct
43 Correct 9 ms 308 KB Output is correct
44 Correct 36 ms 300 KB Output is correct
45 Correct 34 ms 208 KB Output is correct
46 Correct 22 ms 312 KB Output is correct
47 Correct 24 ms 208 KB Output is correct
48 Correct 18 ms 300 KB Output is correct