Follows 10324.c (Total 40 lines):

/* @JUDGE_ID:4461XX 10324 C "divide to groups" */
/* A */

#include<stdio.h>

char in[1000000+1] ;

void doSomething( void )
{
	int i , groupNum ;
	char tmp ;

	tmp = in[0] ;
	in[0] = groupNum = 0 ;
	for( i=1 ; in[i] ; ++i )
		if( in[i]==tmp ) in[i] = groupNum ;
		else{
			tmp = in[i] ;
			in[i] = ++groupNum ;
		}
}
int main( void )
{
	int times , cases , from , to ;
	
	for( times=1 ; gets( in ) ; ++times ){
		doSomething() ;
		
		printf( "Case %d:\n" , times ) ;
		scanf( "%d\n" , &cases ) ;
		for( ; cases ; --cases ){
			scanf( "%d %d\n" , &from , &to ) ;

			if( in[from]==in[to] ) puts( "Yes" ) ;
			else puts( "No" ) ;
		}
	}
	
	return 0 ;
}

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