Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪儿错了啊,大家帮忙看一下啊!!!谢谢~~

Posted by shanshanpt at 2013-10-09 13:43:06 on Problem 1129 and last updated at 2013-10-10 07:55:39
#include <stdio.h>
#include <string.h>

int main()
{
	int  count[27][27], i, j, T, color[27], min_color_i_can, current_max, visit[27];
	char rep[30];

	while( scanf("%d", &T) && T )
	{
		getchar();
		/*
		 * 初始化数组
		 */
		for ( i = 0; i < T; ++i )
		{
			for ( j = 0; j < T; ++j )
			{
				count[i][j] = 0;
			}
		}

		/*
		 * 输入数据
		 */
		for ( i = 0; i < T; ++i )
		{
			gets( rep );

			j = 2;
			while( rep[j] )
			{
				count[rep[0]-'A'][rep[j++]-'A'] = 1;
			}
		}

		/*
		 * 下面进行统计
		 */
		for ( i = 0; i < 27; ++i )
		{
			color[i] = 1;
		}
		
		for ( i = 1; i < T; ++i )
		{
			for ( j = 0; j < 27; ++j )
			{
				visit[j] = 0;
			}
			
			for ( j = 0; j < T; ++j )	
			{
				if ( count[i][j] )
				{
					visit[color[j]] = 1;
				}
			}

			for ( j = 1; j < 27; ++j )
			{
				if ( !visit[j] )
				{
					color[i] = j;
					break;
				}
			}
		}
		
		current_max = color[0];
		for ( i = 1; i < 27; ++i )
		{
			if ( current_max < color[i] )
			{
				current_max = color[i];
			}
		}

		if ( current_max == 1 )
		{
			printf("1 channel needed.\n" );
		}
		else
		{
			printf("%d channels needed.\n", current_max );
		}
	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator