ACM/ICPC Asia Regional Dalian Online 1006 Football Games

Source: Internet
Author: User

Topic Links:

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

problem DescriptionA mysterious country a football world championships---abnormal cups, attracting football teams and fans from all Around the world. This country are so mysterious that none of the information of the Games would be open to the public till the end of all the Matches. And finally only the score of each team would be announced.

At the first phase of the championships, teams is divided intoM groups using the single round robin rule where one and only one game would 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 was tied both score 1 point. The schedule of these games is unknown, only the scores of all team in each group is available.

When those games finished, some insider revealed the There were some false scores in some groups. This have aroused great concern among the pubic, so the the Association of Credits Management (ACM) asks you to judge which Groups ' scores must be false.

InputMultiple test cases, process till end of the input.

The first line contains a positive integersM, which is the number of groups.
TheI-th of the nextMLines begins with a positive integerBi Representing the number of teams in theI-th Group, followed by Bi nonnegative integers representing the score of each team I n this group.


Number of test Cases <= 10
m<= 100
b[i]<= 20000
Score of each team <= 20000

OutputFor each test case, output M lines. Output ' F ' (without quotes) if the scores in the I-th group must is false, output ' T ' (without quotes) otherwise. See samples for detail.

Sample Input23 0 5 12 1 1

Sample OutputFT

Hint:

Test Instructions:

There are teams mm , each group has a bib?i?? team. 22 plays between each group, win plus 2 points, draw each plus 1 points, lose no score. Now tell you the final score for each team in each group and ask if the score sequence is correct.

Exercises

If there is no tie option, to win a point, you can use Landau's theorem to determine, this problem slightly modified the theorem is good. MakeS1s2...snS?1 ?? ,s ? 2 ?? ,.,s ? n ?? Is their scoring sequence, from small to large to shoot a sequence, makingS1s2...snS?1 ?? ≤s ? 2 ?? ≤.≤s ? n ?? , then this sequence is valid, if and only if:

  1. S1s2...siii1S?1??+S? 2?? +.. . +s? I?? ≥i(i−1) , for all1in11≤i≤n−1
  2. S1s2...snnn1S?1??+S? 2?? +.. . +s? N?? =n(n−1) .

The game when the topic did not see clearly, for 0 of the time of the special sentence also to forget, alas.

Code:

#include <cmath> #include <cstdio> #include <cstring> #include <algorithm>using namespace std;    const int MAXN = 20000+10; #define MET (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]&GT;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"); }    }}

ACM/ICPC Asia Regional Dalian Online 1006 Football Games

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.