zoukankan      html  css  js  c++  java
  • 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组球队, 每组有bibi​​支球队. 每组之间两两踢球, 赢得加2分, 平手各加1分, 输的不得分. 现在告诉你每组里面每只球队最后的分数, 问这个分数序列是否正确.

    题解:

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

    1. s1s2...siii1s1​​+s2​​+...+si​​i(i1), 对于所有1in11in1
    2. s1s2...snnn1s1​​+s2​​+...+sn​​=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
    ");
            else
                printf("T
    ");
        }
        }
    }
    
  • 相关阅读:
    get_folder_size.ps1
    python3-database-shelve
    Windows中实现不依赖账户登录的开机启动程序
    SpringBoot+SpringDataJPA如何实现自定义且自由度高的查询[多表,多查询条件,多排序条件,分页,自定义sql封装]
    Windows phone 8.1之数据绑定(Data Binding)
    TextBox使用技巧--转载
    在Eclipse中使用git把项目导入到git中--转载
    运用多种知识点实现一个综合小游戏
    Git帮助之初始化项目设置向导
    如何从Eclipse导入github上的项目源码--转载
  • 原文地址:https://www.cnblogs.com/TAT1122/p/5860206.html
Copyright © 2011-2022 走看看