답안 #1074775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074775 2024-08-25T13:53:36 Z fv3 드문 곤충 (IOI22_insects) C++17
0 / 100
35 ms 684 KB
#include "insects.h"
#include <bits/stdc++.h>
 
using namespace std;
 
int min_cardinality(int N) 
{
  // Find the number of different insect types:
  // Maximum number of insects with 1 being maximum
  // Let that number be K
  // Find another set of K numbers with 2 being the maximum
  // Then 3 and 4 and so on untill it is no longer possible
 
  // The grader is not adaptive:
  vector<int> indicies(N);
  iota(indicies.begin(), indicies.end(), 0);
 
  mt19937 mt(time(0));
  shuffle(indicies.begin(), indicies.end(), mt);
 
  vector<int> in(N);
  vector<int> order;

  int k = 0;
  int insect_cnt = 0;
  for (int i = 0; i < N; i++)
  {
    move_inside(indicies[i]);
    if (press_button() > 1)
    {
      move_outside(indicies[i]);
    }
    else
    {
      k++;
      insect_cnt++;
      order.push_back(i);
      in[i] = 1;
    }
  }

  int l = 1, r = N / k;
  while (l < r)
  {
    int c = (l + r + 1) / 2;
    while (insect_cnt > k * c)
    {
      move_outside(indicies[order.back()]);
      in[order.back()] = 0;
      order.pop_back();
      insect_cnt--;
    }

    for (int i = 0; i < N && insect_cnt < k * c; i++)
    {
      if (in[i]) continue;

      move_inside(indicies[i]);
      if (press_button() > c)
      {
        move_outside(indicies[i]);
      }
      else
      {
        insect_cnt++;
        order.push_back(i);
        in[i] = 1;
      }
    }
    
    if (insect_cnt < k * c)
      r = c - 1;
    else
      l = c;
  }
 
  return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Incorrect 3 ms 436 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Incorrect 3 ms 436 KB Wrong answer.
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 9 ms 344 KB Output is correct
9 Correct 33 ms 436 KB Output is correct
10 Incorrect 35 ms 684 KB Wrong answer.
11 Halted 0 ms 0 KB -