HDU 5873 Football Games "simulation" (ACM/ICPC Asia regional Dalian Online)

Source: Internet
Author: User

Football Games

Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 802 Accepted Submission (s): 309


Problem Descriptiona Mysterious country would hold a football world championships---Abnormal Cup, 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 into M 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 integers M, 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

Source2016 ACM/ICPC Asia Regional Dalian Online

Recommendwange2014 | We have carefully selected several similar problems for you:5877 5875 5872 5871 5870

Statistic | Submit | Discuss | Note

Topic Links:

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

Main topic:

Multiple sets of data (<=10), each group of data has M (m<=100) team, each team has N (n<=20000) team, each team has a round of single-cycle (one team and all other teams only), win 2 points, Ping 1 points, lose 0 points.

Now give N teams a final score and ask if it's legal.

Topic Ideas:

Simulation

Because a match will make the score and +2, so sum!=n* (n-1) is inevitable illegal.

Then consider the assumption that there is no draw, the highest scoring team has a maximum of (N-1) points, the second high (N-2), the team score from small to dozen, from the back to do, remember S for the remaining assignable points.

s+=a[i]-2* (i-1) indicates that the current score deduction of the highest score is also redundant or missing a number of points (if there is a draw will be added to the back by the negative leveling team), when the s<0 indicates that the remaining assignable score is not enough, it is not legal.

All other cases are legal.

1 //2 //by Coolxxx3 //#include <bits/stdc++.h>4#include <iostream>5#include <algorithm>6#include <string>7#include <iomanip>8#include <map>9#include <stack>Ten#include <queue> One#include <Set> A#include <bitset> -#include <memory.h> -#include <time.h> the#include <stdio.h> -#include <stdlib.h> -#include <string.h> - //#include <stdbool.h> +#include <math.h> - #defineMin (a) < (b) ( A):(B)) + #defineMax (a) (a) > (b)? ( A):(B)) A #defineABS (a) ((a) >0? ( A):(-(a))) at #defineLowbit (a) (a& (a)) - #defineSqr (a) ((a) * (a)) - #defineSwap (a) (a) ^= (b), (b) ^= (a), (a) ^= (b)) - #defineMem (A, B) memset (A,b,sizeof (a)) - #defineEPS (1E-10) - #defineJ 10000 in #defineMoD 1000000007 - #defineMAX 0x7f7f7f7f to #definePI 3.14159265358979323 + #pragmaComment (linker, "/stack:1024000000,1024000000") - #defineN 20004 the using namespacestd; *typedefLong LongLL; $ DoubleAnss;Panax Notoginseng LL Aans; - intCas,cass; the intN,m,lll,ans; + intA[n]; A LL sum; the BOOLcmpintAaintBB) + { -     returnaa<BB; $ } $ BOOLjudge () - { -     inti; theLL s=0; -     if(Sum!=1ll*n* (n1))return 1;WuyiSort (a,a+n,cmp); the      for(i=n-1; i>=0; i--) -     { Wus+=i*2-A[i]; -         if(s<0)return 1; About     } $     return 0; - } - intMain () - { A #ifndef Online_judge + //freopen ("1.txt", "R", stdin); the //freopen ("2.txt", "w", stdout); -     #endif $     inti,j,k; the     intx, y, z the //init (); the //for (scanf ("%d", &cass); cass;cass--) the //for (scanf ("%d", &cas), cass=1;cass<=cas;cass++) - //while (~scanf ("%s", s)) in //while (~scanf ("%d", &n)) the      while(~SCANF ("%d",&CAs)) the     { About          while(cas--) the         { thesum=cass=0; thescanf"%d",&n); +              for(i=0; i<n;i++) -             { thescanf"%d",&a[i]);Bayisum+=A[i]; the             } the             if(judge ()) puts ("F"); -             ElsePuts"T"); -         } the     } the     return 0; the } the /* - // the  the // the */
View Code

  

HDU 5873 Football Games "simulation" (ACM/ICPC Asia regional Dalian Online)

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.