2016 ACM/ICPC Asia Regional Dalian Online 1006 Football Games

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2016 ACM/ICPC Asia Regional Dalian Online 1006 Football Games相关的知识,希望对你有一定的参考价值。

题目链接:

http://acm.split.hdu.edu.cn/showproblem.php?pid=5873

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
 

 Hint:

   

题意:

mm组球队, 每组有bib?i??支球队. 每组之间两两踢球, 赢得加2分, 平手各加1分, 输的不得分. 现在告诉你每组里面每只球队最后的分数, 问这个分数序列是否正确.

题解:

如果没有平手选项, 赢得加一分的话, 可以用Landau‘s Theorem判定, 这题稍微修改下这个定理就好了. 令s1s2...sns?1??,s?2??,...,s?n??是他们的得分序列, 从小到大拍个序, 使得s1s2...sns?1??s?2??...s?n??, 那么这个序列合法, 当且仅当:

  1. s1s2...siii1s?1??+s?2??+...+s?i??i(i1), 对于所有1in11in1
  2. s1s2...snnn1s?1??+s?2??+...+s?n??=n(n1).

 比赛的时候题目没看清楚,对于0的时候的特判也给忘了,唉。 

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 20000+10;
#define met(a,b) memset(a,b,sizeof(a))
typedef long long ll;
ll a[maxn];
int main()
{
    int t;
    while(scanf("%d",&t)!=EOF)
    {
    while(t--)
    {
        ll n;
        scanf("%lld",&n);
        ll sum=0,sum1,sum2;
        sum1=2*(n-1);
        sum2=n*(n-1);
        int flag=0;
        for(ll i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
            if(a[i]>sum1)
                flag=1;
            sum+=a[i];
        }
        if(n==0)
        {
            if(a[0]!=0)
                flag=1;
        }
        if(sum!=sum2)
            flag=1;
        sort(a,a+n);
        ll ans=0;
        for(ll i=n-1;i>=0;i--)
        {
            if(a[i]>ans+i*2)
            {
                flag=1;
                break;
            }
            else
                ans+=(i*2-a[i]);
        }
        if(flag)
            printf("F\n");
        else
            printf("T\n");
    }
    }
}

 

以上是关于2016 ACM/ICPC Asia Regional Dalian Online 1006 Football Games的主要内容,如果未能解决你的问题,请参考以下文章

2016 ACM/ICPC Asia Regional Shenyang Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5889

2016 ACM/ICPC Asia Regional Qingdao Online 1002 Cure

2016 ACM/ICPC Asia Regional Qingdao Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5883

2016 ACM/ICPC Asia Regional Shenyang Online