답안 #875475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875475 2023-11-19T20:22:12 Z LucaLucaM CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include "icc.h"
#ifdef LOCAL
#include "grader.cpp"
#endif // LOCAL
#include <vector>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <cstring>

int p[NMAX + 1];

int root(int u) {
  if (p[u] == u) {
    return u;
  }
  return p[u] = root(p[u]);
}

void join(int u, int v) {
  u = root(u), v = root(v);
  p[u] = v;
}

int ask(std::vector<int> a, std::vector<int> b) {
  int sz_a = (int) a.size(), sz_b = (int) b.size();
  int A[sz_a], B[sz_b];
  for (int i = 0; i < sz_a; i++) {
    A[i] = a[i];
  }
  for (int i = 0; i < sz_b; i++) {
    B[i] = b[i];
  }
  return query(sz_a, sz_b, A, B);
}

void run(int n) {
  bool before[n + 1][n + 1];
  memset(before, false, sizeof(before));
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  for (int k = 1; k < n; k++) {
    bool ok = false;
    for (int i = 1; i < n && !ok; i++) {
      for (int j = i + 1; j <= n && !ok; j++) {
        if (!before[i][j] && root(i) != root(j)) {
          before[i][j] = ask({i}, {j});
          if (before[i][j]) {
            join(i, j);
            setRoad(i, j);
            ok = true;
          }
        }
      }
    }
  }
}

Compilation message

icc.cpp:11:7: error: 'NMAX' was not declared in this scope
   11 | int p[NMAX + 1];
      |       ^~~~
icc.cpp: In function 'int root(int)':
icc.cpp:14:7: error: 'p' was not declared in this scope
   14 |   if (p[u] == u) {
      |       ^
icc.cpp:17:10: error: 'p' was not declared in this scope
   17 |   return p[u] = root(p[u]);
      |          ^
icc.cpp: In function 'void join(int, int)':
icc.cpp:22:3: error: 'p' was not declared in this scope
   22 |   p[u] = v;
      |   ^
icc.cpp: In function 'void run(int)':
icc.cpp:41:5: error: 'p' was not declared in this scope
   41 |     p[i] = i;
      |     ^