CF World Football Cup
来源:互联网 发布:医疗人工智能 编辑:程序博客网 时间:2024/05/16 06:08
题意:求出晋级的队伍,并按字典序输出,排序要求是:1.按得分降序,2.按赢球和输球的差的降序,3,按赢的降序,麻烦的是储存数据
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <map>using namespace std;const int MAXN = 200;char Map[MAXN][MAXN];struct node{ int goal; int equal; int defeat; int mark; int sign;}arr[MAXN];int n,cnt;map<string,int>ans;map<int,string>bns;int cmp(node a,node b){ if (a.mark > b.mark) return 1; else if (a.mark < b.mark) return 0; else if (a.goal-a.defeat > b.goal-b.defeat) return 1; else if (a.goal-a.defeat < b.goal-b.defeat) return 0; else return a.goal > b.goal;}int cmp1(node a,node b){ return bns[a.sign] < bns[b.sign];}int main(){ char str[MAXN]; string ch; int cnt = 0; memset(arr,0,sizeof(arr)); scanf("%d%*c",&n); for (int i = 0; i < n; i++){ cin >> ch; ans[ch] = i; bns[i] = ch; arr[i].sign = i; } for (int i = 0; i < n*(n-1)/2; i++){ string a,b; int c,d; cin >> ch; a = b = ch; for (int i = 0; i < ch.length(); i++) if (ch[i] == '-'){ a.erase(a.begin()+i,a.end()); b.erase(b.begin(),b.begin()+i+1); } scanf("%s",str); sscanf(str,"%d:%d",&c,&d); if (c > d){ arr[ans[a]].mark += 3; arr[ans[a]].goal += c; arr[ans[a]].defeat += d; arr[ans[b]].goal += d; arr[ans[b]].defeat += c; } else if (c < d) { arr[ans[b]].mark += 3; arr[ans[b]].goal += d; arr[ans[b]].defeat += c; arr[ans[a]].goal += c; arr[ans[a]].defeat += d; } else { arr[ans[a]].mark += 1; arr[ans[a]].goal += c; arr[ans[a]].defeat += d; arr[ans[b]].mark += 1; arr[ans[b]].goal += d; arr[ans[b]].defeat += c; } } sort(arr,arr+n,cmp); sort(arr,arr+n/2,cmp1); for (int i = 0; i < n/2; i++) cout << bns[arr[i].sign] << endl; return 0;}
- CF World Football Cup
- CF 19A World Football Cup
- cf 19a World Football Cup
- A. World Football Cup
- 【map+审题】#19 A. World Football Cup
- Codeforces 19A World Football Cup 【模拟】
- CodeForces 19A World Football Cup
- cf19A World Football Cup (排序)
- CodeForce 19A World Football Cup (string类应用)
- CodeForces 19A World Football Cup (简单题)
- CodeForces 19A World Football Cup (水题)
- 19AWorld Football Cup
- 【多过程模拟】CodeForce 19A——World Football Cup
- world cup
- CF:96A.Football
- CF:43A. Football
- CF 96A Football
- cf 417 C Football
- CTP5自定义验证
- 在linux上用dd命令实现ghost功能
- java常用转义字符
- 大话设计模式--解释器模式 interpreter -- C++实现实例
- Spring AOP应该用到Spring MVC上不起作用?怎么才能让aop起作用
- CF World Football Cup
- android adb 常用命令
- Android资源类型一
- C#泛型有什么好处
- Holiday模板
- 有关 ORA-00604 错误的总结
- 【C++第七课】---类的静态成员
- 黑马程序员-------异常(finally)
- 随手笔记