Football Games
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 439 Accepted Submission(s): 157
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.
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
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.
如果没有平手选项, 赢得加一分的话, 可以用Landau's Theorem判定, 这题稍微修改下这个定理就好了. 令s1,s2,...,sns_1,s_2,...,s_ns1,s2,...,sn
是他们的得分序列, 从小到大拍个序, 使得s1≤s2≤...≤sns_1 \le s_2 \le ... \le s_ns1≤s2≤...≤sn
, 那么这个序列合法, 当且仅当:
-
s1+s2+...+si≥i(i−1)
对于所有1≤i≤n−11 \le i \le n - 11≤i≤n−1
s1+s2+...+sn=n(n−1)
/******************************
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 ;
}