cf 19a World Football Cup
2015-10-25 21:33
246 查看
#include <iostream> #include <cstdio> #include <algorithm> #include <map> using namespace std; struct node { string na; int points; int scored; int missed; int dif; }nn[55]; bool cmp1(const node &n1,const node &n2) { if(n1.points!=n2.points) return n1.points>n2.points; else if(n1.dif!=n2.dif) return n1.dif>n2.dif; else if(n1.scored!=n2.scored) return n1.scored>n2.scored; } bool cmp2(const node &n1,const node &n2) { return n1.na<n2.na; } int get(string s) { if(s.length()==1) return s[0]-'0'; else if(s.length()==2) return 10*(s[0]-'0')+s[1]-'0'; else if(s.length()==3) return 100; } int n; int main() { scanf("%d",&n); for(int i=0;i<n;i++) cin>>nn[i].na; string ss,s,s1,s2,s3,s4; map<string,int> tp,ts,tm; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { cin>>ss>>s; int p=ss.find('-'); s3=ss.substr(0,p); s4=ss.substr(p+1,ss.length()-1-p); //---- p=s.find(':'); s1=s.substr(0,p); s2=s.substr(p+1,s.length()-1-p); int a1=get(s1); int a2=get(s2); ts[s3]+=a1; tm[s3]+=a2; ts[s4]+=a2; tm[s4]+=a1; if(a1>a2) tp[s3]+=3; else if(a1<a2) tp[s4]+=3; else if(a1==a2) { tp[s3]++; tp[s4]++; } } } for(int i=0;i<n;i++) { nn[i].points=tp[nn[i].na]; nn[i].scored=ts[nn[i].na]; nn[i].missed=tm[nn[i].na]; nn[i].dif=nn[i].scored-nn[i].missed; } sort(nn,nn+n,cmp1); int tt=n/2; sort(nn,nn+tt,cmp2); for(int i=0;i<tt;i++) cout<<nn[i].na<<"\n"; return 0; }
相关文章推荐
- Foundation 之 NSDictionary和NSMutableDictionary
- 创建git私有仓库
- 第十章、国际供应源搜寻中的风险和机会
- (转)Java读带有BOM的UTF-8文件乱码原因及解决方法
- [转] Eclipse的Tomcat插件安装
- lightoj 1356 - Prime Independence 【质因子分解 奇偶构图 + HK优化】
- 第118讲:Hadoop内存需求量及Namenode内存使用详解学习笔记
- maven配置问题
- 不用算术运算符实现两个数的加法(按位异或)
- android中图片的三级cache策略(内存、文件、网络)之三:文件缓存策略 .
- 二叉树中遇到的问题
- Notes on "Understanding the Linux kernel“
- 通过JMS监听Oracle AQ,在数据库变化时触发执行Java程序
- 仅在当前目录编译的通用Makefile
- Java 多维数组遍历
- 让开发板飞——四轴飞控原理
- 2015年10月23日作业
- 初窥Windows Server Container
- Vijos1118 统计单词个数
- OceanBase简介