Submission #627232

# Submission time Handle Problem Language Result Execution time Memory
627232 2022-08-12T11:37:06 Z model_code Rarest Insects (IOI22_insects) C++17
82 / 100
129 ms 416 KB
// correct/solution-invfact-opt.cpp
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

int min_cardinality(int N) {
  int colors = 0;
  vector <bool> mark(N);
  for (int i = N - 1; i >= 0; i--) {
    move_inside(i);
    if (press_button() == 1) {
      colors++;
      mark[i] = true;
    }
    else {
      move_outside(i);
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (mark[i]) {
      move_outside(i);
    }
  }
  
  int ans = N / colors - 1;
  while (true) {
    vector <int> in;
    int B = 0;
    for (int i = 0; i < N; i++) {
      move_inside(i);
      if (press_button() > ans) {
        move_outside(i);
        if (mark[i]) {
          B++;
        }
      }
      else {
        in.push_back(i);
      }
    }
    
    if (B == colors) {
      return ans + 1;
    }
    
    int C = colors - B;
    int M = (int)in.size() - B * ans;
    
    if (C == 1) {
      return M;
    }
    if (M == C * ans) {
      return ans;
    }
    
    for (int x : in) {
      move_outside(x);
    }
    ans = M / C - 1;
  }
}
# 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 1 ms 208 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 6 ms 300 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 5 ms 300 KB Output is correct
9 Correct 9 ms 296 KB Output is correct
10 Correct 7 ms 256 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 6 ms 280 KB Output is correct
13 Correct 6 ms 300 KB Output is correct
14 Correct 5 ms 300 KB Output is correct
15 Correct 5 ms 300 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 7 ms 296 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 8 ms 208 KB Output is correct
20 Correct 8 ms 296 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 5 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 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 6 ms 300 KB Output is correct
7 Correct 3 ms 208 KB Output is correct
8 Correct 5 ms 300 KB Output is correct
9 Correct 9 ms 296 KB Output is correct
10 Correct 7 ms 256 KB Output is correct
11 Correct 5 ms 208 KB Output is correct
12 Correct 6 ms 280 KB Output is correct
13 Correct 6 ms 300 KB Output is correct
14 Correct 5 ms 300 KB Output is correct
15 Correct 5 ms 300 KB Output is correct
16 Correct 6 ms 208 KB Output is correct
17 Correct 7 ms 296 KB Output is correct
18 Correct 6 ms 208 KB Output is correct
19 Correct 8 ms 208 KB Output is correct
20 Correct 8 ms 296 KB Output is correct
21 Correct 3 ms 208 KB Output is correct
22 Correct 5 ms 208 KB Output is correct
23 Correct 23 ms 284 KB Output is correct
24 Correct 17 ms 256 KB Output is correct
25 Correct 13 ms 324 KB Output is correct
26 Correct 37 ms 288 KB Output is correct
27 Correct 11 ms 304 KB Output is correct
28 Correct 23 ms 256 KB Output is correct
29 Correct 27 ms 284 KB Output is correct
30 Correct 20 ms 284 KB Output is correct
31 Correct 28 ms 300 KB Output is correct
32 Correct 32 ms 280 KB Output is correct
33 Correct 46 ms 284 KB Output is correct
34 Correct 20 ms 300 KB Output is correct
35 Correct 40 ms 280 KB Output is correct
36 Correct 42 ms 208 KB Output is correct
37 Correct 51 ms 208 KB Output is correct
38 Correct 44 ms 276 KB Output is correct
39 Correct 31 ms 284 KB Output is correct
40 Correct 21 ms 276 KB Output is correct
41 Correct 10 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 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 36 ms 276 KB Output is correct
8 Correct 19 ms 300 KB Output is correct
9 Correct 37 ms 284 KB Output is correct
10 Partially correct 93 ms 296 KB Output is partially correct
11 Correct 79 ms 208 KB Output is correct
12 Correct 43 ms 280 KB Output is correct
13 Correct 35 ms 280 KB Output is correct
14 Correct 31 ms 320 KB Output is correct
15 Correct 49 ms 276 KB Output is correct
16 Partially correct 52 ms 280 KB Output is partially correct
17 Correct 50 ms 292 KB Output is correct
18 Partially correct 68 ms 296 KB Output is partially correct
19 Partially correct 89 ms 296 KB Output is partially correct
20 Partially correct 93 ms 296 KB Output is partially correct
21 Partially correct 78 ms 280 KB Output is partially correct
22 Partially correct 86 ms 416 KB Output is partially correct
23 Partially correct 54 ms 292 KB Output is partially correct
24 Correct 57 ms 292 KB Output is correct
25 Correct 31 ms 288 KB Output is correct
26 Correct 42 ms 280 KB Output is correct
27 Correct 51 ms 288 KB Output is correct
28 Correct 35 ms 288 KB Output is correct
29 Correct 43 ms 288 KB Output is correct
30 Correct 42 ms 284 KB Output is correct
31 Correct 33 ms 280 KB Output is correct
32 Correct 32 ms 288 KB Output is correct
33 Correct 70 ms 276 KB Output is correct
34 Correct 31 ms 288 KB Output is correct
35 Correct 60 ms 284 KB Output is correct
36 Correct 34 ms 280 KB Output is correct
37 Correct 34 ms 292 KB Output is correct
38 Correct 18 ms 296 KB Output is correct
39 Correct 26 ms 276 KB Output is correct
40 Correct 44 ms 284 KB Output is correct
41 Correct 31 ms 288 KB Output is correct
42 Correct 34 ms 280 KB Output is correct
43 Partially correct 18 ms 208 KB Output is partially correct
44 Partially correct 129 ms 280 KB Output is partially correct
45 Correct 49 ms 292 KB Output is correct
46 Correct 48 ms 344 KB Output is correct
47 Correct 24 ms 208 KB Output is correct
48 Correct 41 ms 284 KB Output is correct