Follows 514.c (Total 29 lines):

/* @JUDGE_ID:4461XX 514 C */
/* A */
#include<stdio.h>
void main( void )
{
        int a[1000] , b[1000] , station[1000] ;
        int num , head_a , head_b , head_s , i ;
        for( i=0 ; i<1000 ; i++ ) a[i] = i+1 ;
        for( scanf( "%d" , &num ) ; ; scanf( "%d" , &num ) , putchar( '\n' ) ){
                if( !num ) break ;
                while( 1 ){
                        scanf( "%d" , &b[0] ) ;
                        if( !b[0] ) break ;
                        for( i=1 ; i<num ; i++ ) scanf( "%d" , &b[i] ) ;
                        for( head_a=head_b=head_s=0 ; head_a<num ; ){
                                station[head_s++] = a[head_a++] ;
                                do{
                                        if( station[head_s-1] == b[head_b] ){
                                                head_s-- ;
                                                head_b++ ;
                                        }
                                        else break ;
                                } while( head_s ) ;
                        }
                        if( !head_s ) puts( "Yes" ) ;
                        else puts( "No" ) ;
                }
        }
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com