QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555453#9237. Messagetiger2005Compile Error//C++142.2kb2024-09-09 23:28:212024-09-09 23:28:21

Judging History

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

  • [2024-09-09 23:28:21]
  • 评测
  • [2024-09-09 23:28:21]
  • 提交

answer

#include <vector>
#include <algorithm>

std::vector<bool> send_packet(std::vector<bool> A);

void send_message(std::vector<bool> M, std::vector<bool> C) {
  int len = M.size();
  M.resize(1025, false);
  for (int i = len + 1; i < 1025; i ++)
    M[i] = true;
  std::vector<std::vector<bool>> occupied(66, std::vector<bool>(31, false));
  std::vector<std::vector<bool>> transfer = occupied;
  for (int i = 0; i < 31; i ++) if (!C[i]) {
    int pos = (i + 1) % 31, x = 1;
    while (C[pos])
      pos = (pos + 1) % 31, ++ x;
    for (int j = 0; j < x; j ++)
      occupied[j][i] = true, transfer[j][i] = j == x - 1;
  }
  int cur = 0;
  for (int i = 0; i < 31; i ++) if (!C[i])
    for (int j = 0; j < 66; j ++) if (!occupied[j][i])
      transfer[j][i] = M[cur ++];
  for (auto packet: transfer)
    send_packet(packet);
}

std::vector<bool> receive_message(std::vector<std::vector<bool>> R) {
  std::vector<int> toward(31);
  std::vector<bool> C(31, true);
  for (int i = 0; i < 31; i ++)
    for (int j = 0; j < 31; j ++) if (R[j][i]) {
      toward[i] = (i + j + 1) % 31;
      break;
    }
  {
    std::vector<int> path, cycle;
    std::vector<bool> vis(31);
    for (int i = 0; i < 31; i ++) if (!vis[i]) {
      path.clear();
      int pos = i;
      while (!vis[pos]) {
        vis[pos] = true;
        path.push_back(pos);
        pos = toward[pos];
      }
      auto ptr = std::find(path.begin(), path.end(), pos);
      if (path.end() - ptr == 16) {
        for (int t = 0; t < 16; t ++)
          cycle.push_back(*(ptr ++));
      }
    }
    for (auto ele: cycle)
      C[ele] = false;
  }
  std::vector<std::vector<bool>> occupied(66, std::vector<bool>(31, false));
  for (int i = 0; i < 31; i ++) if (!C[i]) {
    int pos = (i + 1) % 31, x = 1;
    while (C[pos])
      pos = (pos + 1) % 31, ++ x;
    for (int j = 0; j < x; j ++)
      occupied[j][i] = true;
  }
  std::vector<bool> info(1025);
  int cur = 0;
  for (int i = 0; i < 31; i ++) if (!C[i])
    for (int j = 0; j < 66; j ++) if (!occupied[j][i])
      info[cur ++] = R[j][i];
  int len = 1024;
  while (info[len])
    len --;
  info.resize(len);
  return info;
}

详细

stub.cpp: In function ‘int {anonymous}::sz(const C&)’:
stub.cpp:27:52: error: ‘size’ is not a member of ‘std’; did you mean ‘size_t’?
   27 | template<class C> int sz(const C& c) { return std::size(c); }
      |                                                    ^~~~
      |                                                    size_t
stub.cpp: In function ‘void {anonymous}::write_int_array(const int*, int)’:
stub.cpp:70:13: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’
   70 |         if (int ret = fwrite(arr, sizeof(int), len, fout); len != ret) {
      |             ^~~
stub.cpp: In function ‘void {anonymous}::read_int_array(int*, int)’:
stub.cpp:105:13: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’
  105 |         if (int ret = fread(arr, sizeof(int), len, fin); len != ret) {
      |             ^~~