2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873

Football Games

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

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
 题意:足球比赛,获胜方得2分 失败方不得分 平局各得一分 给你一个小组中m支球队的最终得分  判断得分是否合法
 题解:这个题目乱搞过的
m支球队得分为a1,a2.....am
a1=2*a11+1*a12+0*a13
a2=2*a21+1*a22+0*a23
...
...
am=2*am1+1*am2+0*am3
s1=a11+a21+.....am1
s2=a12+a22+.....am2
s3=a13+a23+.....am3
如果s1==s3&&s2%2==0则合法
下面有hack数据 这种方法错误
 
另外对于camp发出的正解 还是很好理解的
贴:

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

  1. s1+s2+...+si≥i(i−1)对于所有1≤i≤n−11 \le i \le n - 11≤i≤n−1
  2. s1+s2+...+sn=n(n−1)
 
 
错误代码
hack数据
1
4 0 0 6 6
 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
#include<queue>
#define ll __int64
using namespace std;
int n;
int s1,s2,s3;
int exm;
int m;
int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i=; i<=n; i++)
{
scanf("%d",&m);
s1=;
s2=;
s3=;
for(int j=; j<=m; j++)
{
scanf("%d",&exm);
int gg=;
s1=s1+exm/;
gg=gg+exm/;
exm%=;
s2=s2+exm;
gg=gg+exm;
exm=;
if(gg<(m-))
s3=s3+m--gg;
}
if((s2%)==&&(s1==s3))
cout<<"T"<<endl;
else
cout<<"F"<<endl;
}
}
return ;
}

正解代码

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<iomanip>
#include<cmath>
#include<bitset>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef long double ld;
#define INF (1ll<<60)-1
#define Max 1e9
using namespace std;
int T;
int a[];
int main(){
while(scanf("%d",&T)!=EOF){
int n;
for(int cas=;cas<=T;cas++){
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%d",&a[i]);
sort(a+,a+n+);
ll sum=;
int f=;
for(int i=;i<=n;i++){
sum+=a[i];
if(sum<1LL*(i-)*i){
f=;
break;
}
}
if(sum!=1LL*(n-)*n) f=;
if(f) printf("F\n");
else printf("T\n");
}
}
return ;
}
上一篇:Qt开发环境中使用报表控件FastReport遇到的一些问题(二)


下一篇:vmware安装androidx86 (FreeBSD) 系统图解