제출 #628915

#제출 시각아이디문제언어결과실행 시간메모리
628915flashmt드문 곤충 (IOI22_insects)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> findFirstOccurrences(int n, vector<int> &id)
{
  vector<int> res;
  for (int i = 0; i < n; i++)
    if (id[i] < 0)
    {
      move_inside(i);
      if (press_button() > 1) move_outside(i);
      else
      {
        id[i] = size(res);
        res.push_back(i);
      }
    }
  for (int i : res)
    move_outside(i);
  return res;
}

int min_cardinality(int n)
{
  vector<int> id(n, -1);
  auto occurrences = findFirstOccurrences(n, id);
  int typeCnt = size(occurrences);

  int maxC = n / typeCnt;
  if (maxC <= typeCnt)
  {
    int ans = 1;
    while (1)
    {
      auto occ = findFirstOccurrences(n, id);
      if (size(occ) != typeCnt)
        return ans;
      ans++;
    }
  }

  vector<int> cnt(n);
  for (int i = 0; i < n; i++)
    if (id[i] < 0)
    {
      move_inside(i);
      for (int j : occurrences)
      {
        move_inside(j);
        if (press_button() == 2)
        {
          cnt[j]++;
          move_outside(j);
          break;
        }
        move_outside(j);
      }
      move_outside(i);
    }

  int ans = *max_element(begin(cnt), end(cnt)) + 1;
  return ans;
}

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

insects.cpp: In function 'std::vector<int> findFirstOccurrences(int, std::vector<int>&)':
insects.cpp:10:7: error: 'move_inside' was not declared in this scope
   10 |       move_inside(i);
      |       ^~~~~~~~~~~
insects.cpp:11:11: error: 'press_button' was not declared in this scope
   11 |       if (press_button() > 1) move_outside(i);
      |           ^~~~~~~~~~~~
insects.cpp:11:31: error: 'move_outside' was not declared in this scope
   11 |       if (press_button() > 1) move_outside(i);
      |                               ^~~~~~~~~~~~
insects.cpp:19:5: error: 'move_outside' was not declared in this scope
   19 |     move_outside(i);
      |     ^~~~~~~~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:36:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |       if (size(occ) != typeCnt)
      |           ~~~~~~~~~~^~~~~~~~~~
insects.cpp:46:7: error: 'move_inside' was not declared in this scope
   46 |       move_inside(i);
      |       ^~~~~~~~~~~
insects.cpp:50:13: error: 'press_button' was not declared in this scope
   50 |         if (press_button() == 2)
      |             ^~~~~~~~~~~~
insects.cpp:53:11: error: 'move_outside' was not declared in this scope
   53 |           move_outside(j);
      |           ^~~~~~~~~~~~
insects.cpp:56:9: error: 'move_outside' was not declared in this scope
   56 |         move_outside(j);
      |         ^~~~~~~~~~~~
insects.cpp:58:7: error: 'move_outside' was not declared in this scope
   58 |       move_outside(i);
      |       ^~~~~~~~~~~~