//牛牛与二叉树的数组储存//简单的二叉树模拟,要熟知二叉树的性质#include"bits/stdc++.h"usingnamespace std;struct tnode{int data;int lc,rc,father;}node[100005*4];boolcmp(tnode a,tnode b){return a.data<b.data;}intmain(){int n;
cin>>n;int cnt=0;for(int i=1;i<=n;i++){scanf("%d",&node[i].data);if(i==1)node[i].father=-1;else{
node[i].father=node[i/2].data;}if(node[i].data!=-1)cnt++;}for(int i=1;i<=n;i++){if(i<n/2){
node[i].lc=node[i*2].data;node[i].rc=node[i*2+1].data;}elseif(i==n/2){if(n%2==1){
node[i].lc=node[i*2].data;node[i].rc=node[i*2+1].data;}else{
node[i].lc=node[i*2].data;node[i].rc=-1;}}else{
node[i].lc=-1;node[i].rc=-1;}}printf("The size of the tree is %d\n",cnt);printf("Node %d is the root node of the tree\n",node[1].data);int tnum=1;sort(node+1,node+n+1,cmp);for(int i=1;i<=n;i++){if(node[i].data!=-1){printf("The father of node %d is %d, the left child is %d, and the right child is %d\n",node[i].data,node[i].father,node[i].lc,node[i].rc);}}}