Language: C++

#include<iostream>
using namespace std;
#define MAX 100005;
#define NIL -1;

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if ( T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for (  i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
    if ( i ) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

// 再帰的に深さを求める
int rec(int u, int p) {
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);  // 右の兄弟に同じ深さを設定
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ+1を設定
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ) {
    cin >> v >> d;
    for ( j = 0; j < d; j++ ) {
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for ( i = 0; i < n; i++ )
    if ( T[i].p == NIL ) r = i;

  rec(r, 0);

  for ( i = 0; i < n; i++ ) print(i);

  return 0;
}


Compiler output:
a.cc:3:19: error: expected ']' before ';' token
    3 | #define MAX 100005;
      |                   ^
a.cc:8:8: note: in expansion of macro 'MAX'
    8 | Node T[MAX];
      |        ^~~
a.cc:8:11: error: expected unqualified-id before ']' token
    8 | Node T[MAX];
      |           ^
a.cc:3:19: error: expected ']' before ';' token
    3 | #define MAX 100005;
      |                   ^
a.cc:9:10: note: in expansion of macro 'MAX'
    9 | int n, D[MAX];
      |          ^~~
a.cc:9:13: error: expected unqualified-id before ']' token
    9 | int n, D[MAX];
      |             ^
a.cc: In function 'void print(int)':
a.cc:14:26: error: 'T' was not declared in this scope
   14 |   cout << "parent = " << T[u].p << ", ";
      |                          ^
a.cc:15:25: error: 'D' was not declared in this scope
   15 |   cout << "depth = " << D[u] << ", ";
      |                         ^
a.cc:17:22: error: expected primary-expression before ')' token
   17 |   if ( T[u].p == NIL ) cout << "root, ";
      |                      ^
a.cc:18:27: error: expected primary-expression before ')' token
   18 |   else if ( T[u].l == NIL ) cout << "leaf, ";
      |                           ^
a.cc:23:37: error: expected primary-expression before ';' token
   23 |   for (  i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
      |                                     ^
a.cc:23:37: error: expected ')' before ';' token
   23 |   for (  i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
      |       ~                             ^
a.cc: In function 'int rec(int, int)':
a.cc:32:3: error: 'D' was not declared in this scope
   32 |   D[u] = p;
      |   ^
a.cc:33:8: error: 'T' was not declared in this scope
   33 |   if ( T[u].r != NIL ) rec(T[u].r, p);  // 右の兄弟に同じ深さを設定
      |        ^
a.cc:33:22: error: expected primary-expression before ')' token
   33 |   if ( T[u].r != NIL ) rec(T[u].r, p);  // 右の兄弟に同じ深さを設定
      |                      ^
a.cc:34:8: error: 'T' was not declared in this scope
   34 |   if ( T[u].l != NIL ) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ+1を設定
      |        ^
a.cc:34:22: error: expected primary-expression before ')' token
   34 |   if ( T[u].l != NIL ) rec(T[u].l, p + 1);  // 最も左の子に自分の深さ+1を設定
      |                      ^
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
a.cc: In function 'int main()':
a.cc:40:29: error: 'T' was not declared in this scope
   40 |   for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;
      |                             ^
a.cc:46:21: error: 'T' was not declared in this scope
   46 |       if ( j == 0 ) T[v].l = c;
      |                     ^
a.cc:47:12: error: 'T' was not declared in this scope
   47 |       else T[l].r = c;
      |            ^
a.cc:49:7: error: 'T' was not declared in this scope
   49 |       T[c].p = v;
      |       ^
a.cc:53:10: error: 'T' was not declared in this scope
   53 |     if ( T[i].p == NIL ) r = i;
      |          ^
a.cc:53:24: error: expected primary-expression before ')' token
   53 |     if ( T[i].p == NIL ) r = i;
      |                        ^