답안 #876274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876274 2023-11-21T13:33:05 Z Halfjuice 디지털 회로 (IOI22_circuit) C++17
컴파일 오류
0 ms 0 KB
#include <vector>

typedef struct {
  Node* parent;
  vector<Node*> children;
} Node;

void init(int N, int M, int[] P, int[] A) {
  Node[] nodes = new Node[N+M];
  for (int i=0; i<N+M; i++) {
    nodes[i].parent = nodes+P[i];
    nodes[P[i]].children.push_back(nodes+i);
  }
}

int count_ways(int L, int R) {
  return 0;
}

Compilation message

circuit.cpp:4:3: error: 'Node' does not name a type
    4 |   Node* parent;
      |   ^~~~
circuit.cpp:5:3: error: 'vector' does not name a type
    5 |   vector<Node*> children;
      |   ^~~~~~
circuit.cpp:8:31: error: expected ',' or '...' before 'P'
    8 | void init(int N, int M, int[] P, int[] A) {
      |                               ^
circuit.cpp: In function 'void init(int, int, int*)':
circuit.cpp:9:7: error: structured binding declaration cannot have type 'Node'
    9 |   Node[] nodes = new Node[N+M];
      |       ^~
circuit.cpp:9:7: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
circuit.cpp:9:7: error: empty structured binding declaration
circuit.cpp:9:10: error: expected initializer before 'nodes'
    9 |   Node[] nodes = new Node[N+M];
      |          ^~~~~
circuit.cpp:11:5: error: 'nodes' was not declared in this scope
   11 |     nodes[i].parent = nodes+P[i];
      |     ^~~~~
circuit.cpp:11:29: error: 'P' was not declared in this scope
   11 |     nodes[i].parent = nodes+P[i];
      |                             ^
circuit.cpp:9:7: warning: unused structured binding declaration [-Wunused-variable]
    9 |   Node[] nodes = new Node[N+M];
      |       ^~