标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 439 Accepted Submission(s): 157
如果没有平手选项, 赢得加一分的话, 可以用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??
, 那么这个序列合法, 当且仅当:
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
标签:
原文地址:http://www.cnblogs.com/hsd-/p/5860747.html