Submission #838660

# Submission time Handle Problem Language Result Execution time Memory
838660 2023-08-27T14:23:25 Z taher Rarest Insects (IOI22_insects) C++17
25 / 100
256 ms 336 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;

int min_cardinality(int N) {
  int n = N;
  vector<int> in(n);
  
  vector<int> roots;
  for (int i = 0; i < n; i++) {
    move_inside(i);
    if (press_button() == 2) {
      move_outside(i); 
    } else {
      roots.push_back(i);
      in[i] = true; 
    }
  }
  assert((int) roots.size() > 0);
  

  
  if ((int) roots.size() < n / (int) roots.size()) {
    int res = 1234567;
    
    for (int i = 0; i < (int) roots.size(); i++) {
      move_outside(roots[i]); 
    }
    for (int it = 0; it < (int) roots.size(); it++) {
      move_inside(roots[it]);
      int cnt = 1;
      
      for (int j = 0; j < n; j++) {
        if (j == roots[it]) {
          continue; 
        }
        
        move_inside(j);
        if (press_button() == 2) {
          cnt++; 
        }
        move_outside(j);
      }
      
      res = min(res, cnt);
      move_outside(roots[it]); 
    }
    return res;
  } else {
    vector<int> cur_roots(roots.begin(), roots.end());
    int len = 0;
    while ((int) cur_roots.size() == (int) roots.size()) {
      for (int i = 0; i < (int) cur_roots.size(); i++) {
        move_outside(cur_roots[i]); 
      }
      ++len;
      cur_roots.clear();
      for (int i = 0; i < n; i++) {
        if (in[i]) {
          continue; 
        } 
        move_inside(i);
        if (press_button() == 2) {
          move_outside(i); 
        } else {
          cur_roots.push_back(i);
          in[i] = true; 
        }       
      }
    }
    return len;
  }
  return 0;
}
# 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 4 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 12 ms 208 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 12 ms 208 KB Output is correct
16 Correct 13 ms 208 KB Output is correct
17 Correct 23 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 7 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 2 ms 296 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 4 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 12 ms 208 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 4 ms 208 KB Output is correct
11 Correct 3 ms 208 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 3 ms 208 KB Output is correct
14 Correct 10 ms 208 KB Output is correct
15 Correct 12 ms 208 KB Output is correct
16 Correct 13 ms 208 KB Output is correct
17 Correct 23 ms 208 KB Output is correct
18 Correct 5 ms 208 KB Output is correct
19 Correct 7 ms 208 KB Output is correct
20 Correct 2 ms 208 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 2 ms 296 KB Output is correct
23 Correct 15 ms 208 KB Output is correct
24 Correct 7 ms 308 KB Output is correct
25 Correct 158 ms 208 KB Output is correct
26 Correct 115 ms 208 KB Output is correct
27 Correct 20 ms 208 KB Output is correct
28 Correct 10 ms 208 KB Output is correct
29 Correct 37 ms 208 KB Output is correct
30 Correct 251 ms 208 KB Output is correct
31 Correct 39 ms 208 KB Output is correct
32 Correct 56 ms 208 KB Output is correct
33 Correct 87 ms 208 KB Output is correct
34 Correct 112 ms 208 KB Output is correct
35 Correct 111 ms 208 KB Output is correct
36 Correct 114 ms 208 KB Output is correct
37 Correct 59 ms 208 KB Output is correct
38 Correct 29 ms 208 KB Output is correct
39 Correct 8 ms 336 KB Output is correct
40 Correct 10 ms 208 KB Output is correct
41 Correct 9 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 34 ms 208 KB Output is correct
8 Correct 15 ms 316 KB Output is correct
9 Incorrect 256 ms 208 KB Too many queries.
10 Halted 0 ms 0 KB -