QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398129#4565. Rarest Insectshos_lyricCompile Error//C++14901b2024-04-24 22:38:202024-04-24 22:38:21

Judging History

你现在查看的是最新测评结果

  • [2024-04-24 22:38:21]
  • 评测
  • [2024-04-24 22:38:20]
  • 提交

answer

#include "insects.h"

#include <vector>
using std::vector;

#define push move_inside
#define pop move_outside
#define get press_button

// us -> vs, ws
vector<int> us, vs, ws;
void go(int thr) {
  vs.clear();
  ws.clear();
  for (const int u : us) {
    push(u);
    if (get() <= thr) {
      vs.push_back(u);
    } else {
      pop(u);
      ws.push_back(u);
    }
  }
}

int min_cardinality(int N) {
  us.resize(N);
  for (int u = 0; u < N; ++u) us[u] = u;
  
  go(1);
  const int K = vs.size();
  us.swap(ws);
  
  // keep inside: lo insects of each type
  int lo = 1, hi = N / K s+ 1;
  for (; lo + 1 < hi; ) {
    const int mid = (lo + hi) / 2;
    go(mid);
    if ((int)vs.size() == K * (mid - lo)) {
      lo = mid;
      us.swap(ws);
    } else {
      hi = mid;
      for (const int v : vs) pop(v);
      us.swap(vs);
    }
  }
  return lo;
}

详细

implementer.cpp:8:8: warning: inline variables are only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
    8 | static inline constexpr int kMaxQueries = 40000;
      |        ^~~~~~
answer.code: In function ‘int min_cardinality(int)’:
answer.code:35:26: error: expected ‘,’ or ‘;’ before ‘s’
   35 |   int lo = 1, hi = N / K s+ 1;
      |                          ^