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
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
如果没有平手选项, 赢得加一分的话, 可以用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)
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