Language: C++

#include<iostream>
#include<cstdio>
#include<vector>

struct Node{
    int parent;
    int depth;
    int num_of_child;
    std::vector<int> children;
    void NewNode(void){
        parent=-1;
        depth=num_of_child=0;
    }    
};

void calcHeight(std::vector<struct Node> &node,int root_id){
    for(int i=0;i<node[root_id].num_of_child;i++){
         node[node[root_id].children[i]]=node[root_id]+1;
        calcHeight(node,node[root_id].children[i]);
    }
}

int GetRootID(std::vector<struct Node> &node){
    for(int i=0;i<node.size();i++)
        if(node[i].parent==-1) return i;
}

int main(void){
    int n,k,id;
    std::cin>>n;
    std::vector<struct Node> node(n);
    for(int i=0;i<n;i++){
        std::cin>>id>>k;
        node[id].num_of_child=k;
        for(int j=0;j<k;j++){
            int child_id;
            std::cin>>child_id;
            node[id].children.push_back(child_id);
            node[child_id].parent=id;
        }

    }
    int root_id=GetRootID(node);
    calcHeight(node,root_id);

    for(int i=0;i<n;i++){
         if(node[i].parent == -1){
            printf("node %d: parent = -1, depth = 0, root, ",i);
        }else if(node[i].num_of_children == 0){
            printf("node %d: parent = %d, depth = %d, leaf, ",i,node[i].parent,nodes[i].depth);
        }else{
            printf("node %d: parent = %d, depth = %d, internal node, ",i,node[i].parent,node[i].depth);
        }
        printf("[");
        for(int j = 0; j < node[i].num_of_children-1; j++){
            printf("%d, ",node[i].children[j]);
        }
        if(node[i].num_of_children > 0){
            printf("%d",node[i].children[node[i].num_of_children-1]);
        }
        printf("]\n");
    }
    return 0;
}


Compiler output:
a.cc: In function 'void calcHeight(std::vector<Node>&, int)':
a.cc:18:55: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'Node'} and 'int')
   18 |          node[node[root_id].children[i]]=node[root_id]+1;
a.cc: In function 'int main()':
a.cc:49:26: error: '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'struct Node'} has no member named 'num_of_children'; did you mean 'num_of_child'?
   49 |         }else if(node[i].num_of_children == 0){
      |                          ^~~~~~~~~~~~~~~
      |                          num_of_child
a.cc:50:80: error: 'nodes' was not declared in this scope; did you mean 'node'?
   50 |             printf("node %d: parent = %d, depth = %d, leaf, ",i,node[i].parent,nodes[i].depth);
      |                                                                                ^~~~~
      |                                                                                node
a.cc:55:36: error: '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'struct Node'} has no member named 'num_of_children'; did you mean 'num_of_child'?
   55 |         for(int j = 0; j < node[i].num_of_children-1; j++){
      |                                    ^~~~~~~~~~~~~~~
      |                                    num_of_child
a.cc:58:20: error: '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'struct Node'} has no member named 'num_of_children'; did you mean 'num_of_child'?
   58 |         if(node[i].num_of_children > 0){
      |                    ^~~~~~~~~~~~~~~
      |                    num_of_child
a.cc:59:50: error: '__gnu_cxx::__alloc_traits<std::allocator<Node>, Node>::value_type' {aka 'struct Node'} has no member named 'num_of_children'; did you mean 'num_of_child'?
   59 |             printf("%d",node[i].children[node[i].num_of_children-1]);
      |                                                  ^~~~~~~~~~~~~~~
      |                                                  num_of_child
a.cc: In function 'int GetRootID(std::vector<Node>&)':
a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^