Follows 539.c (Total 60 lines):

/* @JUDGE_ID:4461XX 539 C */
/* A */
#include<stdio.h>
#define MAX 25

struct MAP{
	int walkable ;
	int used ;
}map[MAX][MAX] ;
int max ;
void initial( int n )
{
	int i , j ;

	for( i=0 ; i<n ; i++ )
		for( j=0 ; j<n ; j++ )
			map[i][j].walkable = map[i][j].used = 0 ;
	max = 0 ;
}
void input( int m )
{
	int i , j ;

	for( ; m ; m-- ){
		scanf( "%d %d" , &i , &j ) ;

		map[i][j].walkable = map[j][i].walkable = 1 ;
	}
}
void recursive( int level , int poi , int n )
{
	int i ;

	if( level>max ) max = level ;
	for( i=0 ; i<n ; i++ )
		if( map[poi][i].walkable )
			if( !map[poi][i].used ){
				map[poi][i].used = map[i][poi].used = 1 ;
				recursive( level+1 , i , n ) ;
				map[poi][i].used = map[i][poi].used = 0 ;
			}
}
int main( void )
{
	int i , n , m ;

	while( 1 ){
		scanf( "%d %d" , &n , &m ) ;
		if( !n && !m ) break ;

		initial( n ) ;
		input( m ) ;
		
		for( i=0 ; i<n ; i++ ) recursive( 0 , i , n ) ;
		printf( "%d\n" , max ) ;
	}

	return 0 ;
}
/* @END_OF_SOURCE_CODE */

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