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

Posted 半根毛线code

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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_ns1​​,s2​​,...,sn​​是他们的得分序列, 从小到大拍个序, 使得s1≤s2≤...≤sns_1 \\le s_2 \\le ... \\le s_ns1​​s2​​...sn​​, 那么这个序列合法, 当且仅当:

  1. s1+s2+...+si≥i(i−1)对于所有1≤i≤n−11 \\le i \\le n - 11in1
  2. s1+s2+...+sn=n(n−1)
 
 
错误代码
hack数据
1
4 0 0 6 6
 1 /******************************
 2 code by drizzle
 3 blog: www.cnblogs.com/hsd-/
 4 ^ ^    ^ ^
 5  O      O
 6 ******************************/
 7 #include<bits/stdc++.h>
 8 #include<iostream>
 9 #include<cstring>
10 #include<cstdio>
11 #include<map>
12 #include<algorithm>
13 #include<queue>
14 #define ll __int64
15 using namespace std;
16 int n;
17 int s1,s2,s3;
18 int exm;
19 int m;
20 int main()
21 {
22     while(scanf("%d",&n)!=EOF)
23     {
24     for(int i=1; i<=n; i++)
25     {
26         scanf("%d",&m);
27         s1=0;
28         s2=0;
29         s3=0;
30         for(int j=1; j<=m; j++)
31         {
32             scanf("%d",&exm);
33             int gg=0;
34             s1=s1+exm/2;
35             gg=gg+exm/2;
36             exm%=2;
37             s2=s2+exm;
38             gg=gg+exm;
39             exm=0;
40             if(gg<(m-1))
41                 s3=s3+m-1-gg;
42         }
43         if((s2%2)==0&&(s1==s3))
44             cout<<"T"<<endl;
45         else
46             cout<<"F"<<endl;
47     }
48     }
49     return 0;
50 }

 

正解代码

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<string>
 6 #include<vector>
 7 #include <ctime>
 8 #include<queue>
 9 #include<set>
10 #include<map>
11 #include<list>
12 #include<stack>
13 #include<iomanip>
14 #include<cmath>
15 #include<bitset>
16 #define mst(ss,b) memset((ss),(b),sizeof(ss))
17 ///#pragma comment(linker, "/STACK:102400000,102400000")
18 typedef long long ll;
19 typedef long double ld;
20 #define INF (1ll<<60)-1
21 #define Max 1e9
22 using namespace std;
23 int T;
24 int a[100100];
25 int main(){
26     while(scanf("%d",&T)!=EOF){
27         int n;
28         for(int cas=1;cas<=T;cas++){
29             scanf("%d",&n);
30             for(int i=1;i<=n;i++) scanf("%d",&a[i]);
31             sort(a+1,a+n+1);
32             ll sum=0;
33             int f=0;
34             for(int i=1;i<=n;i++){
35                 sum+=a[i];
36                 if(sum<1LL*(i-1)*i){
37                     f=1;
38                     break;
39                 }
40             }
41             if(sum!=1LL*(n-1)*n) f=1;
42             if(f) printf("F\\n");
43             else printf("T\\n");
44         }
45     }
46     return 0;
47 }

 

以上是关于2016 ACM/ICPC Asia Regional Dalian Online 1006 /HDU 5873的主要内容,如果未能解决你的问题,请参考以下文章

2016 ACM/ICPC Asia Regional Shenyang Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5889

2016 ACM/ICPC Asia Regional Qingdao Online 1002 Cure

2016 ACM/ICPC Asia Regional Qingdao Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5883

2016 ACM/ICPC Asia Regional Shenyang Online