Submission #627654

# Submission time Handle Problem Language Result Execution time Memory
627654 2022-08-12T18:11:21 Z Fischer Rarest Insects (IOI22_insects) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;

const int maxn = 2010;
bool in[maxn];

pair<bool, int> p(int x, int N) {
  for (int i = 1; i <= N; ++i) {
    move_inside(i);
    in[i] = 1;
    if (press_button() > x) {
      move_outside(i);
      in[i] = 0;
    }
  }

  for (int i = 1; i <= N; ++i) {
    if (in[i]) {
      move_outside(i);
    }
  }

  int cnt = 0, bad = 0;
  for (int i = 1; i <= N; ++i) {
    if (in[i]) {
      move_inside(i);
      if (press_buton() >= x) {
        move_outside(i);
        bad += 1;
      }
      cnt += 1;
      in[i] = 0;
    }
  }

  return {cnt == bad * (x - 1), bad};
}

int min_cardinality(int N) {

  pair<bool, int> temp;
  int lo = 1, hi = min(N, 1000);
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    if ((temp = p(mid, N)).first) lo = mid;
    else hi = mid-1;
  }

  if (lo == 1000 && temp.second == 1) return N;
  return lo;
}

Compilation message

insects.cpp: In function 'std::pair<bool, int> p(int, int)':
insects.cpp:28:11: error: 'press_buton' was not declared in this scope; did you mean 'press_button'?
   28 |       if (press_buton() >= x) {
      |           ^~~~~~~~~~~
      |           press_button