제출 #629759

#제출 시각아이디문제언어결과실행 시간메모리
629759hltk드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include "insects.h"

#include <vector>
#include <iostream>

using namespace std;

int min_cardinality(int n) {
  int types = 0;
  vector<int> y, inds;
  for (int i = 0; i < n; ++i) {
    move_inside(i);
    if (press_button() == 1) {
      types++;
      y.push_back(i);
    } else {
      inds.push_back(i);
      move_outside(i);
    }
  }
  if (types == 1 || types == n) {
    return 1 ^ n ^ types;
  }
  auto test = [&](int k) {
    vector<int> x = y;
    for (int i : inds) {
      move_inside(i);
      if (press_button() > k) {
        move_outside(i);
      } else {
        x.push_back(i);
      }
    }
    for (int i : x) {
      if (!binary_search(y.begin(), y.end(), i)) {
        move_outside(i);
      }
    }
    return x.size() < k * types;
  };
  int l = 1, r = n - 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (test(m + 1)) r = m;
    else l = m + 1;
  }
  return l;
}

컴파일 시 표준 에러 (stderr) 메시지

insects.cpp: In lambda function:
insects.cpp:35:12: error: 'binary_search' was not declared in this scope
   35 |       if (!binary_search(y.begin(), y.end(), i)) {
      |            ^~~~~~~~~~~~~
insects.cpp:39:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     return x.size() < k * types;
      |            ~~~~~~~~~^~~~~~~~~~~