제출 #390854

#제출 시각아이디문제언어결과실행 시간메모리
390854AlexPop28버섯 세기 (IOI20_mushrooms)C++14
0 / 100
1 ms200 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL_DEFINE
const int K = 2;
#else
const int K = 100;
#endif

int count_mushrooms(int n) {
  if (n <= K) {
    int ans = 0;
    for (int i = 1; i < n; ++i) {
      vector<int> curr = {0, i};
      ans += use_machine(curr);
    }
    return n - ans;
  }

  /*
  vector<int> pos_a, pos_b;
  int i;
  for (i = 1; (int)max(pos_a.size(), pos_b.size()) < K; ++i) {
    vector<int> curr = {0, i};
    if (use_machine(curr) == 0) {
      pos_a.emplace_back(i);
    } else {
      pos_b.emplace_back(i);
    }
  }
  bool type = false;
  auto pos = pos_a;
  if (pos_b.size() > pos_a.size()) {
    type = true;
    pos = pos_b;
  }
  */

  int i = 1;
  int ans = 1;
  while (i < n) {
    vector<int> curr = {0};
    for (int j = 0; j < K && i < n; ++j) {
      curr.emplace_back(i++);
      curr.emplace_back(0);
    }
    int total = (curr.size() - 1) / 2;
    int ret = total - use_machine(curr) / 2;
    ans += ret;
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...