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:wa了n次,请帮忙看一下代码

Posted by 674396380 at 2010-10-25 18:56:48 on Problem 1083
In Reply To:wa了n次,请帮忙看一下代码 Posted by:lake_house at 2008-09-27 10:13:40
> //1083,解题思想,考察每个s【i】,t【i】对删除与其可兼容的对(即可同时发生的对),并把该对加入到检验条件,以检查下对数
> 
> #include <iostream>
> using namespace std;
> int main()
> {
> 	int T,N,sum=0,i,m,j,s[200],t[200];
> 	char flag[200];
> 	char biao;
> 	int rank[200],temp;
> 	cin >> T;
> 	while(T--)
> 	{
> 		cin >> N;
> 		for (i = 0;i < N;i ++)
> 		{
> 			flag[i] = '1';
> 			cin >> s[i] >> t[i];
> 			if (s[i]>t[i])//使s【i】小于t【i】
> 			{
> 				temp = s[i];
> 				s[i] = t[i];
> 				t[i] = temp;
> 			}	
> 		}	
> 		sum = 0;
> 		for(i = 0;i < N;i ++)
> 		{
> 			temp = -1;
> 			if (flag[i] == '1')//s[i],t【i】对开始发生
> 			{
> 				sum = sum + 10;
> 				rank[++temp] = i ;//把i对加入为检验条件
> 				flag[i] = '0';
> 				for (j = i +1;j < N;j ++)//检验剩下的对
> 				{	
> 					biao = '0';
> 					for (m = 0;m <= temp;m++)
> 					{
> 						if (flag[j]=='0'||(flag[j]=='1'&&(s[j]>t[rank[m]]||s[rank[m]]>t[j])))
> 						{
> 							continue;
> 						}
> 						if (flag[j] == '1')
> 						{
> 							biao = '1';
> 							break;
> 						}
> 					}
> 					if (biao == '0'&&flag[j]=='1') 
> 					{
> 						flag[j] = '0';
> 						rank[++temp] = j;
> 					}
> 
> 				}
> 			}
> 		}
> 		cout << sum << endl;
> 	}
> 
> 	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