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

Re:数据太弱,可以水过 0MS(贴有点问题但AC的代码)

Posted by xnxylxh at 2012-11-22 01:37:28 on Problem 1129
In Reply To:数据太弱,可以水过 0MS(贴有点问题但AC的代码) Posted by:szy532164656 at 2012-11-08 22:32:58
> #include<iostream>
> #include<string>
> using namespace std;
> 
> int main()
> {
> 	int number;
> 	string input;
> 	while (true)
> 	{
> 		cin>>number;
> 		if ( number == 0 )
> 			break;
> 		int mark[26] = {0};
> 		mark[0] = 1;
> 		bool relation[26][26] = {false};
> 		int maxMark = 1;
> 		for ( int count = 0 ; count < number ; count ++ )
> 		{
> 			cin>>input;
> 			int lenght = input.length();
> 			int selfNum = input.at(0) - 'A';
> 			if ( lenght >= 3 )
> 			{
> 				for ( int i = 2 ; i < lenght ; i ++ )
> 				{
> 					int num = input.at(i) - 'A'; 
> 					relation[selfNum][num] = true;
> 				}
> 			}
> 		}
> 		for ( int i = 1 ; i < number ; i ++ )
> 		{
> 			bool color[27] = {false};
> 			for ( int j = 0 ; j < number ; j ++ )
> 			{
> 
> 				if ( relation[i][j] && i != j )
> 				{
> 					color[mark[j]] = true;
> 				}
> 			}
> 			for ( int j = 1 ; j <= number ; j ++  )
> 			{
> 				if ( !color[j] )
> 				{
> 					mark[i] = j;
> 					break;
> 				}
> 			}
> 			if ( mark[i] > maxMark )
> 			{
> 				maxMark = mark[i];
> 				if ( maxMark >= 4 )
> 				{
> 					maxMark = 4;
> 					break;
> 				}
> 			}
> 		}
> 		if ( maxMark == 1 )
> 			cout<<maxMark<<" channel needed."<<endl;
> 		else
> 			cout<<maxMark<<" channels needed."<<endl;
> 	}
> }
> 
> 6
> A:BEF
> B:AC
> C:BD
> D:CEF
> E:ADF
> F:ADE
> 结果为3   A(1)B(2)C(3)D(1)E(2)F(3)
> 这组数据按以上算法得出结果4.

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