Language: C

#include<stdio.h>
#define MAX 100005
#define NIL -1
   
struct Node{
    int p;
    int l;
    int r;
};
struct Node np[MAX];
int depth = 0;
int hileft = 0;
int hiright = 0;
   
   
int get_depth(int u){
   
    if(np[u].p == NIL) return 0;
    if(np[u].p != NIL){
        depth++;
        get_depth(np[u].p);
    }
    return depth;
}
   
int degree(int u){
    if (np[u].l == NIL && np[u].r == NIL) return 0;
    else if(np[u].l != NIL && np[u].r != NIL)  return 2;
    else  return 1;
}
   
int sibling(int u){
   
    if(np[u].p == NIL) {
        return NIL;
    }
    else if(np[np[u].p].l == u) {
        return np[np[u].p].r;
    }
    else {
        return np[np[u].p].l;
    }
}
   
int hight(int u){
   
    int hileft = 0;
    int hiright = 0;
   
    if(np[u].l != -1) {
        hileft = hight(np[u].l) + 1;
    }
    if(np[u].r != -1){
        hiright = hight(np[u].r) + 1;
    }
    if(hileft < hiright){
        return hiright;
    }
    else {
        return hileft;
    }
}
   
void print(int u){
   
    printf("node %d: ",u);
    printf("parent = %d, ",np[u].p);
    printf("sibling = %d, ",sibling(u));
    printf("degree = %d, ",degree(u));
   
    depth = 0;
   
    printf("depth = %d, ",get_depth(u));
    printf("height = %d, ",hight(u));
   
    if(np[u].p == NIL)printf("root\n");
    else if(np[u].l == NIL && np[u].r == NIL) {
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
}
   
   
int main(){
    int i, j;
    int d, v, c, l;
    int n,tmp;
   
    scanf("%d", &n);
   
    for (i = 0; i < n; i++) {
        np[i].p = np[i].l = np[i].r = NIL;      // ?????????
    }
    for (i = 0; i <n ; i++){
        scanf("%d %d %d", &v, &d, &c);
        np[d].p = np[c].p = v;
        np[v].l = d;
        np[v].r = c;
    }
   
    for (i = 0; i < n; i++ ) {
        print(i);
    }
    return 0;
}

Compile Error Logs:
You are not authorized to see the message.

???????????????
Judge: 8/8	C	CPU: 00.00 sec	Memory: 612 KB	Length: 1847 B	2015-06-11 14:28	2015-06-11 14:28
???????????±?????????????????????
Case #	Verdict	CPU Time	Memory	In	Out	Case Name
Case #1:	: Accepted	00.00 sec	612 KB	38 B	376 B	1.in
Case #2:	: Accepted	00.00 sec	612 KB	10 B	75 B	2.in
Case #3:	: Accepted	00.00 sec	612 KB	31 B	315 B	3.in
Case #4:	: Accepted	00.00 sec	612 KB	52 B	531 B	4.in
Case #5:	: Accepted	00.00 sec	612 KB	66 B	686 B	5.in
Case #6:	: Accepted	00.00 sec	612 KB	52 B	553 B	6.in
Case #7:	: Accepted	00.00 sec	612 KB	164 B	1594 B	7.in
Case #8:	: Accepted	00.00 sec	608 KB	199 B	1955 B	8.in

< prev |	1	/	8	| next >	 		 : Accepted        00.00 sec        612 KB
 
Judge Input #1 ( in1.txt | 38 B)		Judge Output #1 ( out1.txt | 376 B)
5
3 4 0
4 -1 -1
1 -1 -1
2 -1 -1
0 1 2
node 0: parent = 3, sibling = 4, degree = 2, depth = 1, height = 1, internal node
node 1: parent = 0, sibling = 2, degree = 0, depth = 2, height = 0, leaf
node 2: parent = 0, sibling = 1, degree = 0, depth = 2, height = 0, leaf
node 3: parent = -1, sibling = -1, degree = 2, depth = 0, height = 2, root
node 4: parent = 3, sibling = 0, degree = 0, depth = 1, height = 0, leaf
Comments
 
 ??\????????§??????
 
Categories
 
 
Free Tags
 
 

Compiler output:
main.c:109:1: error: unknown type name 'Compile'
  109 | Compile Error Logs:
      | ^~~~~~~
main.c:109:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
  109 | Compile Error Logs:
      |               ^~~~
main.c:114:12: error: stray '\302' in program
  114 | ???????????<U+00B1>?????????????????????
      |            ^~~~~~~~
main.c:115:6: error: stray '#' in program
  115 | Case #  Verdict CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:116:6: error: stray '#' in program
  116 | Case #1:        : Accepted      00.00 sec       612 KB  38 B    376 B   1.in
      |      ^
main.c:116:73: error: invalid suffix "in" on floating constant
  116 | Case #1:        : Accepted      00.00 sec       612 KB  38 B    376 B   1.in
      |                                                                         ^~~~
main.c:117:6: error: stray '#' in program
  117 | Case #2:        : Accepted      00.00 sec       612 KB  10 B    75 B    2.in
      |      ^
main.c:117:73: error: invalid suffix "in" on floating constant
  117 | Case #2:        : Accepted      00.00 sec       612 KB  10 B    75 B    2.in
      |                                                                         ^~~~
main.c:118:6: error: stray '#' in program
  118 | Case #3:        : Accepted      00.00 sec       612 KB  31 B    315 B   3.in
      |      ^
main.c:118:73: error: invalid suffix "in" on floating constant
  118 | Case #3:        : Accepted      00.00 sec       612 KB  31 B    315 B   3.in
      |                                                                         ^~~~
main.c:119:6: error: stray '#' in program
  119 | Case #4:        : Accepted      00.00 sec       612 KB  52 B    531 B   4.in
      |      ^
main.c:119:73: error: invalid suffix "in" on floating constant
  119 | Case #4:        : Accepted      00.00 sec       612 KB  52 B    531 B   4.in
      |                                                                         ^~~~
main.c:120:6: error: stray '#' in program
  120 | Case #5:        : Accepted      00.00 sec       612 KB  66 B    686 B   5.in
      |      ^
main.c:120:73: error: invalid suffix "in" on floating constant
  120 | Case #5:        : Accepted      00.00 sec       612 KB  66 B    686 B   5.in
      |                                                                         ^~~~
main.c:121:6: error: stray '#' in program
  121 | Case #6:        : Accepted      00.00 sec       612 KB  52 B    553 B   6.in
      |      ^
main.c:121:73: error: invalid suffix "in" on floating constant
  121 | Case #6:        : Accepted      00.00 sec       612 KB  52 B    553 B   6.in
      |                                                                         ^~~~
main.c:122:6: error: stray '#' in program
  122 | Case #7:        : Accepted      00.00 sec       612 KB  164 B   1594 B  7.in
      |      ^
main.c:122:73: error: invalid suffix "in" on floating constant
  122 | Case #7:        : Accepted      00.00 sec       612 KB  164 B   1594 B  7.in
      |                                                                         ^~~~
main.c:123:6: error: stray '#' in program
  123 | Case #8:        : Accepted      00.00 sec       608 KB  199 B   1955 B  8.in
      |      ^
main.c:123:73: error: invalid suffix "in" on floating constant
  123 | Case #8:        : Accepted      00.00 sec       608 KB  199 B   1955 B  8.in
      |                                                                         ^~~~
main.c:127:13: error: stray '#' in program
  127 | Judge Input #1 ( in1.txt | 38 B)                Judge Output #1 ( out1.txt | 376 B)
      |             ^
main.c:127:62: error: stray '#' in program
  127 | Judge Input #1 ( in1.txt | 38 B)                Judge Output #1 ( out1.txt | 376 B)
      |                                                              ^
main.c:141:4: error: stray '\' in program
  141 |  ??\????????§??????
      |    ^
main.c:141:13: error: stray '\302' in program
  141 |  ??\????????<U+00A7>??????
      |             ^~~~~~~~