답안 #876285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876285 2023-11-21T13:45:18 Z Halfjuice 디지털 회로 (IOI22_circuit) C++17
컴파일 오류
0 ms 0 KB
#include <vector>
 
using namespace std;
 
struct _Node {
  _Node* parent;
  vector<_Node*> children;
} Node;

vector<Node> nodes;

void init(int N, int M, vector<int> P, vector<int> A) {
  nodes.empty();
  for (int i=0; i<N+M; i++) {
    nodes.push_back(move(Node()))
    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:10:12: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   10 | vector<Node> nodes;
      |            ^
circuit.cpp:10:12: note:   expected a type, got 'Node'
circuit.cpp:10:12: error: template argument 2 is invalid
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:13:9: error: request for member 'empty' in 'nodes', which is of non-class type 'int'
   13 |   nodes.empty();
      |         ^~~~~
circuit.cpp:15:11: error: request for member 'push_back' in 'nodes', which is of non-class type 'int'
   15 |     nodes.push_back(move(Node()))
      |           ^~~~~~~~~
circuit.cpp:15:31: error: no match for call to '(_Node) ()'
   15 |     nodes.push_back(move(Node()))
      |                               ^
circuit.cpp:17:10: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   17 |     nodes[P[i]].children.push_back(nodes[i]);
      |          ^
circuit.cpp:17:41: error: invalid types 'int[int]' for array subscript
   17 |     nodes[P[i]].children.push_back(nodes[i]);
      |                                         ^