Questions surface: http: //220.180.209.150: 38888 / problem / 572
Well, this topic is really very simple ah. . Forgive my face began to question wrong. .
In fact it is the first to point to the root of the tree, and then read each incoming junction and than inserted into the tree.
The only problem then, is the problem of the size of the array. . md. . 100 open array, then only 90 points. . Therefore, the weight of myself ~ ~
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 #include<stack> 7 #include<deque> 8 #include<algorithm> 9 #define ll long long 10 using namespace std; 11 const int oo=0x3f3f3f3f; 12 const int N=1005; 13 14 int n,t=1; 15 int a[N]; 16 17 int get(){ 18 char zy=getchar(); 19 int z=1,y=0; 20 while(zy>'9'||zy<'0'){ 21 if(zy=='-') z=-1; 22 zy=getchar(); 23 } 24 while(zy>='0'&&zy<='9'){ 25 y=(y<<1)+(y<<3)+zy-'0'; 26 zy=getchar(); 27 } 28 return z*y; 29 } 30 31 int Max(int a,int b){return a>b?a:b;} 32 33 int main(){ 34 //freopen(".in","r",stdin); 35 //freopen(".out","w",stdout); 36 n=get(); 37 a[1]=get(); 38 for(int i=1;i<n;i++){ 39 int u=get(),l=1; 40 while(a[l]!=0){ 41 if(a[l]>u) l*=2; 42 else l=l*2+1; 43 } 44 a[l]=u; 45 t=Max(t,l); 46 } 47 for(int i=1;i<=t;i++){ 48 if(a[i]){ 49 printf("%d ",a[i]); 50 } 51 } 52 if(t!=n) printf("\nno\n"); 53 else printf("\nyes\n"); 54 return 0; 55 }