답안 #893119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893119 2023-12-26T14:26:34 Z Trisanu_Das 드문 곤충 (IOI22_insects) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int min_cardinality(int N) {
  vector <int> rest;
  auto attempt = [&](int x, int v) {
    move_inside(x);
    if (press_button() != v) rest.push_back(x), move_outside(x);
  };
  for (int i = 0; i < N; i++) attempt(i, 1);
  int ans = 1, cnt = N - (int)rest.size();
  for (; !rest.empty(); sol++) {
    vector <int> tmp = rest;
    rest.clear();
    shuffle(tmp.begin(), tmp.end(), rng);
    for (int i = 0; i < tmp.size(); i++)
      if (i < rest.size() + cnt) attempt(tmp[i], ans + 1);
      else rest.push_back(tmp[i]);
    if (tmp.size() < rest.size() + cnt) break;
  }
  return ans;
}

Compilation message

insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:15:25: error: 'sol' was not declared in this scope
   15 |   for (; !rest.empty(); sol++) {
      |                         ^~~
insects.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < tmp.size(); i++)
      |                     ~~^~~~~~~~~~~~
insects.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |       if (i < rest.size() + cnt) attempt(tmp[i], ans + 1);
      |           ~~^~~~~~~~~~~~~~~~~~~