Football Games

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 379    Accepted Submission(s): 133


Problem Description
A mysterious country will hold a football world championships---Abnormal Cup, attracting football teams and fans from all around the world. This country is so mysterious that none of the information of the games will be open to the public till the end of all the matches. And finally only the score of each team will be announced.
  
  At the first phase of the championships, teams are divided into M groups using the single round robin rule where one and only one game will be played between each pair of teams within each group. The winner of a game scores 2 points, the loser scores 0, when the game is tied both score 1 point. The schedule of these games are unknown, only the scores of each team in each group are available.
  
  When those games finished, some insider revealed that there were some false scores in some groups. This has aroused great concern among the pubic, so the the Association of Credit Management (ACM) asks you to judge which groups' scores must be false.
 

Input
Multiple test cases, process till end of the input.
  
  For each case, the first line contains a positive integers M, which is the number of groups.
  The i-th of the next M lines begins with a positive integer Bi representing the number of teams in the i-th group, followed by Bi nonnegative integers representing the score of each team in this group.


number of test cases <= 10
M<= 100
B[i]<= 20000
score of each team <= 20000
 

Output
For each test case, output M lines. Output ``F" (without quotes) if the scores in the i-th group must be false, output ``T" (without quotes) otherwise. See samples for detail.
 

Sample Input
2 3 0 5 1 2 1 1
 

Sample Output
F T
 

Source



思路:
就是给了你一个组内几个队伍的积分,看你有没有办法达到这种情况。我的想法是,用a数组储存实际读入的每个数,b数组储存平均值n-1(价值一开始所有队的所有比赛都是平局)。然后就挨个比较每个位置对应的数的差值是多少,+n就相当于赢n场,-n就相当于输n场,然后把这些差值求和看等不等于0。如果等于0,那么说明可以达到这个状态并且保证每两个队之间只有一场比赛(如果有多的比赛那么总分数就会增加);如果不等于0,则说明不能通过赢球输球来达到这一状态。并且这里还要加两个条件,第一,任何一个队的赢的常数不会超过n-1,所以得分会≤2*(n-1);再者就是0出现的次数不能超过2,因为如果有两个2的话,那么他们之间进行的那场比赛就没有谁得分,这肯定是不行的。


代码:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

int a[100000+5];
int b[100000+5];

int main()
{
	//freopen("in.txt","r",stdin);
	int t;
	while(scanf("%d",&t)!=EOF)
	{
		while(t--)
		{
			int n;
			scanf("%d",&n); 
			long long cnt=0;
			bool flag=true;
			int cntt=0;
			for(int i=0;i<n;i++)
			{
				scanf("%d",&a[i]);
				if(a[i]>2*(n-1))flag=false;
				if(a[i]==0)cnt++;
			} 
			for(int i=0;i<n;i++)
			{
				b[i]=n-1;
			} 
			long long ans=0;
			for(int i=0;i<n;i++)
			{
				ans+=b[i]-a[i];
			}
			if(ans==0&&flag==true&&cnt<=1)printf("T\n");
			else printf("F\n");			
	   }
	}
	return 0;
}