HDU 5873 Football Games 竞赛图

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Tawn0000/article/details/82392988

                                             Football Games

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


 

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

2016 ACM/ICPC Asia Regional Dalian Online

题解:

F题

Landau's Theorem定理

定理解释与证明

如果没有平手选项, 赢得加一分的话,可以直接用兰道定理解决,将所有的得分s从小到大排序。

\forall 1\leqslant i\leqslant n-1 \sum_{i = 1}^{n} s[i] >= \binom{i}{2}            当i = 1 时  只能取=号。

现在加入了平手选项,所以将定理改动一下就可以了(具体证明,目前看不太懂)

将得分s从小到大进行排序

该竞赛图合理需满足两个条件

  • s​1​​+s​2​​+...+s​i​​≥i(i−1), 对于所有的i < n 必须恒成立
  • s1+s2+...+sn=n(n−1)
#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int maxn = 2e4+100;
const int INF = 0x3f3f3f3f;

int n,T;
int a[maxn];

int main()
{
    while(~scanf("%d",&T))
    {
      while(T--)
    {
      scanf("%d",&n);
      int s = 0;
      bool t = true;
      for(int i = 0; i < n; i++) scanf("%d",&a[i]);
      sort(a,a+n);
      for(int i = 0; i < n; i++)
      {
        s += a[i];
        if(i == n-1) break;
        if(s < 1LL*i*(i+1))
        {t = false; break;}
      }

      if(s != 1LL*n*(n-1))  t = false;
      if(t) printf("T\n");
      else printf("F\n");
    }
  }
  return 0;
}

猜你喜欢

转载自blog.csdn.net/Tawn0000/article/details/82392988