Submission #1008587

# Submission time Handle Problem Language Result Execution time Memory
1008587 2024-06-26T14:41:50 Z oyber Rarest Insects (IOI22_insects) C++17
0 / 100
0 ms 344 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> uniqu;
vector<int> insects;
int N;

bool check_num(int num) {
  vector<bool> used(N, false);
  for (int i = 0; i < int(insects.size()); i++) {
    move_inside(insects[i]);
    if (press_button() >= num) {
      move_outside(insects[i]);
      continue;
    }
    used[i] = true;
  }

  bool valid = true;
  for (int i = 0; i < int(uniqu.size()); i++) {
    move_inside(uniqu[i]);
    if (press_button() != num) {
      move_outside(uniqu[i]);
      valid = false;
      break;
    }
    move_outside(uniqu[i]);
  }

  for (int i = 0; i < N; i++) {
    if (used[i]) {
      move_outside(i);
    }
  }
  return valid;
}

int min_cardinality(int n) {
  N = n;
  int types = 0;
  for (int i = 0; i < N; i++) {
    move_inside(i);
    if (press_button() > 1) {
      move_outside(i);
      insects.push_back(i);
      continue;
    }
    types++;
    uniqu.push_back(i);
  }

  int l = 1;
  int r = N/types+1;
  while (l < r) {
    int m = (l+r)/2;
    if (check_num(m)) {
      r = m;
    } else {
      l = m+1;
    }
  }
  return l;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -