#include  < iostream >
#include 
< vector >

using   namespace  std;

int  main()
{
    
int   test;
    scanf(
" %d " & test);
    
    
int  d[ 25 ];
    
while ( test --  )
    
{
        
int  n;
        vector
< char >   t;
        
        scanf(
" %d " & n );
        
for int  i =   0 ; i <  n;  ++ i ) scanf( " %d " , d +  i );
        
        
int  cu =  d[ 0 ];
        
for int  i =   0 ; i <  cu;  ++ i )  t.push_back(  ' ( '  ); t.push_back(  ' ) '  );
        
        
for int  i =   1 ; i <  n;  ++ i )
        
{
            
int   a =  d[i] -  cu;
            cu
=  d[i];
            
            
for int  j =   0 ; j <  a; j ++  )
            t.push_back( 
' ( '  );
            
            t.push_back( 
' ) '  );
        }

        
        
bool   b =   false ;
        
for ( size_t i =   0 ; i <  t.size();  ++ i )
        
{
            
if ( t[i] ==   ' ) '  )
            
{
                
int  num =   0 ;
                
int  j =  i;
                
                
for ( ; j >=   0 ; j --  )
                
{
                    
if ( t[j] ==   ' ) '  ) num ++ ;
                    
else              num -- ;
                    
                    
if (  num ==   0  )  break ;
                }

                
                
for int  k =  j; k <=  i;  ++ k )
                
if (  t[k] ==   ' ( '  ) num ++ ;
                
                
if ! b )
                
{        
                    printf(
" %d " , num );
                    b
=   true ;
                }

                
else  printf( "  %d " , num );
            }
    
        }

        
        printf(
" \n " );
    }

    
    
return   0 ;
}

posted on 2008-10-30 19:44 Darren 阅读(335) 评论(0)  编辑 收藏 引用 所属分类: 未分类

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理