QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#447615#4632. Card SharkzlxFTHCompile Error//C++141.4kb2024-06-18 17:17:152024-06-18 17:17:15

Judging History

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

  • [2024-06-18 17:17:15]
  • 评测
  • [2024-06-18 17:17:15]
  • 提交

answer

#include <algorithm>
#include <cstdlib>
#include <iostream>
using std::cin;

const int N = 1e6 + 5;

void shutd() {
  std::cout << -1 << "\n";
  exit(0);
}

int tp;
int deg[N], cur[N], st[N];
std::vector<int> G[N];

void add(int u, int v) {
  G[u].emplace_back(v);
  deg[u]--;
  deg[v]++;
}

void dfs(int u) {
  for (int &i = cur[u]; i < G[u].size();) {
    int v = G[u][i++];
    dfs(v);
  }
  st[++tp] = u;
}

int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, b;
  cin >> n >> m >> b;
  for (int i = 0; i < n; ++i) {
    std::string s;
    cin >> s;
    auto p = std::find(s.begin(), s.end(), '1');
    int u = p - s.begin();
    if (u >= m) shutd();
    add(n + u, i);
    while (1) {
      auto q = std::find(p + 1, s.end(), '1');
      if (q == s.end()) break;
      if (q - p - 1 != m - 1) shutd();
      p = q;
    }
    int v = s.end() - p - 1;
    if (v >= m) shutd();
    add(i, n + m + v);
  }
  int tot = n + 2 * m + 2, s = tot - 2, t = tot - 1;
  add(s, n + b - 1);
  add(n + m + m - b, t);
  for (int i = 0; i < m; ++i) {
    for (int j = 0, num = deg[n + m + i]; j < num; ++j) {
      add(n + m + i, n + m - i - 1);
    }
  }
  for (int i = 0; i < tot - 2; ++i) {
    if (deg[i]) shutd();
    std::sort(G[i].begin(), G[i].end());
  }
  dfs(s);
  while (tp) {
    int u = st[tp--];
    if (u < n) std::cout << u + 1 << " ";
  }
  std::cout << "\n";
  return 0;
}

详细

answer.code:15:6: error: ‘vector’ in namespace ‘std’ does not name a template type
   15 | std::vector<int> G[N];
      |      ^~~~~~
answer.code:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    3 | #include <iostream>
  +++ |+#include <vector>
    4 | using std::cin;
answer.code: In function ‘void add(int, int)’:
answer.code:18:3: error: ‘G’ was not declared in this scope
   18 |   G[u].emplace_back(v);
      |   ^
answer.code: In function ‘void dfs(int)’:
answer.code:24:29: error: ‘G’ was not declared in this scope
   24 |   for (int &i = cur[u]; i < G[u].size();) {
      |                             ^
answer.code: In function ‘int main()’:
answer.code:63:15: error: ‘G’ was not declared in this scope
   63 |     std::sort(G[i].begin(), G[i].end());
      |               ^