Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
#include <list>
using namespace std;


//?°???\???????????????public?????????
class Node {
public:
  int id;       //??????
  int parent;   //???
  int sibling;  //??????
  int depth;    //??±???
  int height;   //??????
  string type;  //?¨????

  int degree;   //????????°
  int left, right;
public:

  Node(int id, int left, int right): id(id), left(left), right(right)
  {
    depth = parent = -1;
    int t=0;
    if(left != -1) t++;
    if(right != -1) t++;
    degree = t;
  }
  void print(){
  if(parent == -1)  type = "root";
  else if(!degree) type = "leaf";
  else              type = "internal node";
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", id, parent, sibling, degree, depth, height, type.c_str());
  }
};



int search(vector<Node> &v, int id, int sibling, int depth){
  v[id].depth = depth;
  v[id].sibling = sibling;
  int height1 = 0;
  int height2 = 0;
  if(v[id].left != -1){
    height1 = search(v, v[id].left, v[id].right, depth+1);
  }
  if(v[id].right != -1){
    height2 = search(v, v[id].right, v[id].left, depth+1);
  }
  height1 = max(height1, height2);

  v[id].height = height1;

  if(v[id].sibling){
    return height1 + 1;
  }else{
    return height1;
  }
}

bool asc(const Node &right, const Node &left){return right.id < left.id;}

int main(void){
  int n;
  cin >> n;
  vector<Node> nodes(100);

  //??\?????¨
  for(int i=0;i<n;i++){
    int id, left, right;
    cin >> id >> left >> right;
    Node node(id, left, right);
    nodes[i] = node;
  }

  sort(nodes.begin(), nodes.end(), asc);

  //????????¨
  for(int i=0;i<n;i++){
    //parent
    nodes[nodes[i].left].parent = nodes[i].id;
    nodes[nodes[i].right].parent = nodes[i].id;
  }
  //deg, dep, sib
  for(int i=0;i<n;i++){
    if(nodes[i].parent == -1){
      nodes[i].height = search(nodes, i, -1, 0) - 1;
    }
  }

  //????????¨
  for(int i=0;i<n;i++){
    nodes[i].print();
  }

  return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/alloc_traits.h:33,
                 from /usr/include/c++/14/ext/alloc_traits.h:34,
                 from /usr/include/c++/14/bits/basic_string.h:39,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = Node; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Node*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Node*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = Node*; _Size = long unsigned int; _Tp = Node]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1720:36:   required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = Node; _Alloc = std::allocator<Node>; size_type = long unsigned int]'
 1720 |           std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1721 |                                            _M_get_Tp_allocator());
      |                                            ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:558:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = Node; _Alloc = std::allocator<Node>; size_type = long unsigned int; allocator_type = std::allocator<Node>]'
  558 |       { _M_default_initialize(__n); }
      |         ^~~~~~~~~~~~~~~~~~~~~
a.cc:74:25:   required from here
   74 |   vector<Node> nodes(100);
      |                         ^
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'Node::Node()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:3: note: candidate: 'Node::Node(int, int, int)'
   29 |   Node(int id, int left, int right): id(id), left(left), right(right)
      |   ^~~~
a.cc:29:3: note:   candidate expects 3 arguments, 0 provided
a.cc:16:7: note: candidate: 'Node::Node(const Node&)'
   16 | class Node {
      |       ^~~~
a.cc:16:7: note:   candidate expects 1 argument, 0 provided
a.cc:16:7: note: candidate: 'Node::Node(Node&&)'
a.cc:16:7: note:   candidate expects 1 argument, 0 provided