map+string容器的应用(D题Football Match)
来源:互联网 发布:软件开发就业前景 编辑:程序博客网 时间:2024/06/05 21:03
问题 D : Football Match
题目描述
如今,足球已经成为了全世界最受欢迎的运动。许多国家都有自己的足球职业联赛。FIFA计划邀请各国的俱乐部组成一个大型的国际联赛,但手动排名毕竟太麻烦了。于是他们找到了你。
排名规则如下:
1. 一队如赢得一场比赛积3分,平一场积1分,负一场积0分。
2. 首先,队伍按总积分排序。如果两个队伍积分相同,则净胜球多的队排在前面。净胜球数为总进球数减去总失球数。
3. 如果两个队伍有相同的积分以及净胜球数,那么将按他们的名字升序排列。
输入格式
输入数据第一行包含一个整数m(m<=10000),表示比赛场数。其后m行每行给出一场比赛的信息。格式如下:
队名1 得分1:得分2 队名2
其中队名不超过20个字符,得分不超过100。假定任何联赛队伍都至少参加了一场比赛。
输出
输出相应的排名表,一行一个队伍。格式如下:
Id Nm w d l Pt Gd
"Id"是队伍的编号,从1开始。"Nm" 是队名。"w", "d" 和 "l" 分别表示这个队伍的胜场数,平场数,负场数。"Pt"表示队伍积分。"Gd"表示队伍净胜球数。
样例输入
4
Liverpool 1:0 ManchesterU
ManchesterU 3:0 Leeds
Arsenal 2:2 Liverpool
Leeds 1:5 Arsenal
样例输出
1 Arsenal 1 1 0 4 4
2 Liverpool 1 1 0 4 1
3 ManchesterU 1 0 1 3 2
4 Leeds 0 0 2 0 -7
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<queue>#include<string>#include<map>using namespace std;const int N=10010;struct team{ string name; int w,d,l,pt,gd;} t[N];bool cmp(team a,team b){ if(a.pt==b.pt) { if(a.gd==b.gd) return a.name<b.name; return a.gd>b.gd; } return a.pt>b.pt;}int n,cnt;map<string,int> Map;int get_num(string s)//返回每个人对应结点{ if(Map.find(s)==Map.end())//没有搜索到该键值 { Map[s]=cnt; t[cnt].name=s; t[cnt].w=t[cnt].d=t[cnt].l=t[cnt].pt=t[cnt].gd=0; cnt++; } return Map[s];}int main(){ //freopen("C:\\Users\\Administrator\\Desktop\\kd.txt","r",stdin); while(~scanf("%d",&n)) { int x1,x2; cnt=0; string str1,str2; for(int i=0; i<n; i++) { char ch; cin>>str1>>x1>>ch>>x2>>str2; //scanf("%s%d:%d%s",s1,&x1,&x2,s2); int x=get_num(str1); int y=get_num(str2); t[x].gd+=(x1-x2); t[y].gd+=(x2-x1); if(x1==x2) { t[x].d++; t[x].pt++; t[y].d++; t[y].pt++; } else if(x1>x2) { t[x].w++; t[x].pt+=3; t[y].l++; } else if(x1<x2) { t[y].w++; t[y].pt+=3; t[x].l++; } } sort(t,t+cnt,cmp); for(int i=0; i<cnt; i++) { cout<<i+1<<" "<<t[i].name<<" "<<t[i].w<<" "<<t[i].d<<" "<<t[i].l<<" "<<t[i].pt<<" "<<t[i].gd<<endl; } } return 0;}
- map+string容器的应用(D题Football Match)
- ZOJ 2524- Football Match (模拟+map)
- SCU4490 Lisp em(string和map容器的应用)
- D. Innokenty and a Football League----map
- C++ map容器的应用
- zju-1159-map容器的应用
- 容器map的应用:CodeForces - 501B
- hdu-6015map容器的应用
- Map容器与multimap容器应用的小知识
- map容器简单应用
- map容器应用
- C++ string和map容器实现简单的英文翻译
- CodeForce 19A World Football Cup (string类应用)
- HDU4585Shaolin Map容器简单应用
- nyoj 数数、(map容器的初次尝试应用)
- map容器的应用:hdu 1004 Let the Balloon Rise
- stl之map容器的原理及应用
- 【This VI】LabVIEW Match 1D String Array.vi
- 关于批处理中屏蔽命令行信息输出
- Reporting打印分页
- HDU 1028 Ignatius and the Princess III(母函数)
- Windows下ORACLE 10g安装与操作(创建数据库)图解
- 《安卓应用开发学习》——关于隐藏ActionBar标题栏的问题
- map+string容器的应用(D题Football Match)
- 如何在csdn中设置blog链接
- sql 函数
- 基本语言细节--《深度探索C++对象模型》--(1)Object Lessions----总结点
- Android内存管理试验——浅谈ImageView的Bitmap的使用
- 水仙花数
- 【弱智版**别人不要看**哪里有设置自己可见的啊???】导出excel功能~~~~~~弯路
- Android处理图片OOM的若干方法小结
- 数据结构 - C语言版 - 串 所有基本操作