2016 ICPC 大连网络赛 HDU 5873 Football Games

来源:互联网 发布:软件测试管理体系 编辑:程序博客网 时间:2024/05/31 19:46

Football Games

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


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
23 0 5 12 1 1
 

Sample Output
FT
 

【题意】一些队伍在参加足球比赛,这个比赛是赢的一队得2分,输的一队得0分,平局各自得一分,问给出的得分情况是否合法?

【解题方法】乱搞,满足下面3个条件就可以过掉这个题了,首先总分要是n*(n-1),每一个队的分数不超过2*(n-1),得分为奇数的队数是偶数个。

【补充】还有官方题解是Landau's Theorem。大概解释是先将分数从小到大排序一下,那么对任意前i个人的总分,必须不小于他们所能够得到的分数,即i*(i-1),同时总分必须是n*(n-1)。另外,如果没有平局,并且只是胜者获得1分,同样可以使用这个定理,只要改变前i个人所能获得的分数即可,即C(i,2),同时,总分也必须等于C(n,2)。好像是类似于竞赛图的东西,具体可以看这个维基百科--https://en.wikipedia.org/wiki/Tournament_%28graph_theory%29

【AC 代码】

////Created by just_sort 2016/9/12 09:48//Copyright (c) 2016 just_sort.All Rights Reserved//#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;int a[100010];int main(){    int T,n;    while(~scanf("%d",&T))    {        while(T--)        {            scanf("%d",&n);            for(int i=1; i<=n; i++) scanf("%d",&a[i]);            bool ok=1;            for(int i=1; i<=n; i++)            {                if(a[i]>2*(n-1)) ok=0;            }            LL ans=0;            for(int i=1; i<=n; i++) ans+=1LL*a[i];            if(ans!=1LL*n*(n-1)) ok=0;            int cnt=0;            for(int i=1; i<=n; i++)            {                if(a[i]%2==1) cnt++;            }            if(cnt%2==1) ok=0;            if(ok) puts("T");            else puts("F");        }    }    return 0;}


0 0
原创粉丝点击