답안 #1009054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1009054 2024-06-27T08:24:05 Z oyber 드문 곤충 (IOI22_insects) C++17
0 / 100
155 ms 672 KB
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> uniqu;
vector<int> insects;
int N;

bool check_num(int num) {
  //printf("num: %d\n", num);
  vector<bool> used(N, false);
  for (int i = 0; i < int(insects.size()); i++) {
    move_inside(insects[i]);
    if (press_button() >= num) {
      move_outside(insects[i]);
      continue;
    }
    used[i] = true;
  }

  bool valid = true;
  for (int i = 0; i < int(uniqu.size()); i++) {
    move_inside(uniqu[i]);
    if (press_button() != num) {
      move_outside(uniqu[i]);
      valid = false;
      break;
    }
    move_outside(uniqu[i]);
  }

  for (int i = 0; i < N; i++) {
    if (used[i]) {
      move_outside(i);
    }
  }
  //printf("valid: %d\n", int(valid));
  return valid;
}

int min_cardinality(int n) {
  N = n;
  int types = 0;
  for (int i = 0; i < N; i++) {
    move_inside(i);
    if (press_button() > 1) {
      move_outside(i);
      insects.push_back(i);
      continue;
    }
    types++;
    uniqu.push_back(i);
  }

  for (int i = 0; i < int(uniqu.size()); i++) {
    move_outside(uniqu[i]);
  }


  int l = 1;
  int r = N+1;
  while (l < r) {
    int m = (l+r)/2;
    if (check_num(m)) {
      l = m+1;
    } else {
      r = m;
    }
  }
  return r-1;

  /*for (int i = 1; i <= N/types; i++) {
    if (!check_num(i)) {
      return i-1;
    }
  }
  return N/types;*/
}
# 결과 실행 시간 메모리 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 Incorrect 0 ms 344 KB Wrong answer.
5 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 Incorrect 0 ms 344 KB Wrong answer.
5 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 Partially correct 0 ms 344 KB Output is partially correct
6 Partially correct 0 ms 344 KB Output is partially correct
7 Partially correct 121 ms 672 KB Output is partially correct
8 Correct 23 ms 596 KB Output is correct
9 Partially correct 151 ms 432 KB Output is partially correct
10 Partially correct 131 ms 600 KB Output is partially correct
11 Partially correct 155 ms 448 KB Output is partially correct
12 Partially correct 66 ms 344 KB Output is partially correct
13 Incorrect 150 ms 672 KB Wrong answer.
14 Halted 0 ms 0 KB -