Language: C

int main(){
  int n,i,j,k,c,flag,min;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].p=-1;
    u[i].de=0;
  }
  struct node sw;
  for(i=0;i<n;i++){
    scanf("%d %d",&u[i].id,&u[i].chil);
    for(j=0;j<u[i].chil;j++){
      scanf("%d",&u[i].c[j]);
    }
  }
  for(i=0;i<=n-2;i++){
    min=i;
    for(j=i;j<=n-1;j++){
      if(u[j].id<u[min].id){
	min=j;
	flag=1;
      }
    }
    if(flag==1){
      flag=0;
    }
    sw=u[i];
    u[i]=u[min];
    u[min]=sw;
  }
for(i=0;i<n;i++){
  if(u[i].chil==0)strcpy(u[i].type,"leaf");
  for(j=0;j<u[i].chil;j++){  
    u[u[i].c[j]].p=u[i].id;
  }
 }
 
 for(i=0;i<n;i++){
   if(u[i].p==-1){
     strcpy(u[i].type,"root");
     u[i].de=0;
   }
   else if(strcmp(u[i].type,"leaf")!=0){
     strcpy(u[i].type,"internal node");
   }
 }
 for(i=0;i<n;i++){
   dep=0;
   u[i].de=depth(u,i);
 }
 for(i=0;i<n;i++){
   printf("node %d: parent = %d, depth = %d, %s, [",u[i].id,u[i].p,u[i].de,u[i].type);
   if(u[i].chil!=0 && u[i].chil!=1){
     printf("%d,",u[i].c[0]);
     for(j=1;j<u[i].chil-1;j++){
       printf(" %d,",u[i].c[j]); 
     }
     printf(" %d]\n",u[i].c[u[i].chil-1]);
   }
   else if(u[i].chil==1)printf("%d]\n",u[i].c[0]);
   else printf("]\n");
 }
 return 0;
}

int depth(struct node *a,int i){
  if((a+i)->p==-1)return dep;
  else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
}

Compiler output:
main.c: In function 'main':
main.c:3:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    3 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:3:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    3 |   scanf("%d",&n);
      |   ^~~~~
main.c:3:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:6:5: error: 'u' undeclared (first use in this function)
    6 |     u[i].p=-1;
      |     ^
main.c:6:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:15: error: storage size of 'sw' isn't known
    9 |   struct node sw;
      |               ^~
main.c:32:19: error: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration]
   32 |   if(u[i].chil==0)strcpy(u[i].type,"leaf");
      |                   ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'strcpy'
  +++ |+#include <string.h>
    1 | int main(){
main.c:32:19: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch]
   32 |   if(u[i].chil==0)strcpy(u[i].type,"leaf");
      |                   ^~~~~~
main.c:32:19: note: include '<string.h>' or provide a declaration of 'strcpy'
main.c:40:6: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch]
   40 |      strcpy(u[i].type,"root");
      |      ^~~~~~
main.c:40:6: note: include '<string.h>' or provide a declaration of 'strcpy'
main.c:43:12: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
   43 |    else if(strcmp(u[i].type,"leaf")!=0){
      |            ^~~~~~
main.c:43:12: note: include '<string.h>' or provide a declaration of 'strcmp'
main.c:44:6: warning: incompatible implicit declaration of built-in function 'strcpy' [-Wbuiltin-declaration-mismatch]
   44 |      strcpy(u[i].type,"internal node");
      |      ^~~~~~
main.c:44:6: note: include '<string.h>' or provide a declaration of 'strcpy'
main.c:48:4: error: 'dep' undeclared (first use in this function)
   48 |    dep=0;
      |    ^~~
main.c:49:12: error: implicit declaration of function 'depth' [-Wimplicit-function-declaration]
   49 |    u[i].de=depth(u,i);
      |            ^~~~~
main.c:52:4: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   52 |    printf("node %d: parent = %d, depth = %d, %s, [",u[i].id,u[i].p,u[i].de,u[i].type);
      |    ^~~~~~
main.c:52:4: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:52:4: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:52:4: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: At top level:
main.c:66:18: warning: 'struct node' declared inside parameter list will not be visible outside of this definition or declaration
   66 | int depth(struct node *a,int i){
      |                  ^~~~
main.c: In function 'depth':
main.c:67:8: error: invalid use of undefined type 'struct node'
   67 |   if((a+i)->p==-1)return dep;
      |        ^
main.c:67:11: error: invalid use of undefined type 'struct node'
   67 |   if((a+i)->p==-1)return dep;
      |           ^~
main.c:67:26: error: 'dep' undeclared (first use in this function); did you mean 'depth'?
   67 |   if((a+i)->p==-1)return dep;
      |                          ^~~
      |                          depth
main.c:68:13: error: invalid use of undefined type 'struct node'
   68 |   else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
      |             ^
main.c:68:16: error: invalid use of undefined type 'struct node'
   68 |   else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
      |                ^~
main.c:68:38: error: invalid use of undefined type 'struct node'
   68 |   else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
      |                                      ^
main.c:68:41: error: invalid use of undefined type 'struct node'
   68 |   else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
      |                                         ^~