CF19A World Football Cup 题解
Content
有 \(n\) 个球队参加一场足球比赛,比赛排名前 \(\dfrac{n}{2}\) 的队伍将会进入下一轮的淘汰赛。比赛将会打 \(\dfrac{n(n-1)}{2}\) 场,胜者得 \(3\) 分,负者得 \(0\) 分,平局双方各得 \(1\) 分。排行榜上首先会按球队的积分从大到小排序,如果积分相同将会比较净胜球数(胜场比另一方领先的球数的总和减去负场比另一方落后的球数的总和的值),如果净胜球数相同会比较进球数,如果进球数还相同则会比较字典序。试求出能够晋级淘汰赛的 \(\dfrac{n}{2}\) 个队伍。
数据范围:\(1\leqslant n\leqslant 50\),球队名不超过 \(30\) 个字符,单场双方的进球数都不会超过 \(100\)。另根据 CF 官网给出的数据可得,\(n\) 保证是偶数。
Solution
看啥做啥的模拟题。
我们可以通过 \(\texttt{map}\) 直接映射得到球队名所属的球队的积分、胜场比另一方领先的球数的总和、负场比另一方落后的球数的总和、进球数。然后按照如上的关键字次序排序,便可以得到前 \(\dfrac{n}{2}\) 名的球队。
Code
int n;
string s[57], win[57];
map<string, int> q, goal, wingoal, losegoal;
struct team {
string name;
int score, wingoals, goals;
bool operator < (const team& dxy) const {
if(score != dxy.score) return score > dxy.score;
else if(wingoals != dxy.wingoals) return wingoals > dxy.wingoals;
else if(goals != dxy.goals) return goals > dxy.goals;
return name < dxy.name;
}
}teams[57];
int main() {
getint(n);
_for(i, 1, n) cin >> s[i];
_for(i, 1, n * (n - 1) / 2) {
string a, team1 = "", team2 = ""; int x, y;
cin >> a; scanf("%d:%d", &x, &y);
int len = a.size(), flag = 1;
_for(j, 0, len - 1) {
if(a[j] == '-') flag++;
else if(flag == 1) team1 += a[j];
else if(flag == 2) team2 += a[j];
}
goal[team1] += x, goal[team2] += y;
if(x > y) q[team1] += 3, wingoal[team1] += (x - y), losegoal[team2] += (x - y);
else if(x == y) q[team1] += 1, q[team2] += 1;
else q[team2] += 3, wingoal[team2] += (y - x), losegoal[team1] += (y - x);
}
_for(i, 1, n)
teams[i] = (team){s[i], q[s[i]], wingoal[s[i]] - losegoal[s[i]], goal[s[i]]};
sort(teams + 1, teams + n + 1);
_for(i, 1, n / 2) win[i] = teams[i].name;
sort(win + 1, win + n / 2 + 1);
_for(i, 1, n / 2) cout << win[i] << endl;
return 0;
}
CF19A World Football Cup 题解的更多相关文章
- $CF19A\ World\ Football\ Cup$
炒鸡\(6\)批的模拟题. 注意的是输入 把握好空格 大小写. 根据题目的这句话来排序 积分榜是按照以下原则制作的:胜利一个队得3分,平分1分,失败0分. 首先,球队按积分顺序排在积分榜上,分数相等比 ...
- Hdoj 2289.Cup 题解
Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we kn ...
- Codeforces Beta Round #19
A. World Football Cup #include <bits/stdc++.h> using namespace std; ; char name[N][N]; map&l ...
- Codeforces Round #585 (Div. 2) A. Yellow Cards(数学)
链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup ha ...
- [C++]Yellow Cards - GYM - 102348A(Practice *) - CodeForces
1 Problem Description Problem The final match of the Berland Football Cup has been held recently. Th ...
- A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题
---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) 题解
真心简单的一场比赛 就是坑比较多(自己太蠢) A是一个水题 3分钟的时候过了 B也是一个比较简单的题 类似的套路见得多了 但是我当时可能比较困 想了一会才想出来 19分钟的时候过掉了 C同样很显然 性 ...
- Bubble Cup 11 - Finals [Online Mirror, Div. 1]题解 【待补】
Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robo ...
随机推荐
- 测试平台系列(82) 解决APScheduler重复执行的问题
大家好~我是米洛! 我正在从0到1打造一个开源的接口测试平台, 也在编写一套与之对应的完整教程,希望大家多多支持. 欢迎关注我的公众号测试开发坑货,获取最新文章教程! 回顾 上一节我们编写了在线执行R ...
- es的rest风格的api文档
rest风格的api put http://127.0.0.1:9200/索引名称/类型名称/文档id (创建文档,指定文档id) post http://127.0.0.1:9200/索引名称/类型 ...
- Qt5加载SVG格式的图片并更颜色
QIcon MainWindow::qiconFromSvg(QString svg_path, QString color) { QPixmap img(svg_path); QPainter qp ...
- Matlab 代码注释
Matlab 代码注释 一直在找类似doxygen一样将程序注释发表成手册的方法,现在发现,Matlab的publish功能自己就能做到. Publish 简介 并非所有注释都能作为文本进行输出,MA ...
- Redis—怎么查看Linux有没有安装Redis,如何启动Redis
1.检测是否有安装redis-cli和redis-server [root@localhost bin]# whereis redis-cli redis-cli: /usr/bin/redis-cl ...
- C#表格,表格信息、GridView使用。
page: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="test1.a ...
- 【转载】HBase基本数据操作详解【完整版,绝对精品】
转载自: http://blog.csdn.net/u010967382/article/details/37878701 概述 对于建表,和RDBMS类似,HBase也有namespace的概念,可 ...
- set、multiset深度探索
set/multiset的底层是rb_tree,因此它有自动排序特性.set中的元素不允许重复必须独一无二,key与value值相同,multiset中的元素允许重复. set的模板参数key即为关键 ...
- Java实现 HTTP/HTTPS请求绕过证书检测
java实现 HTTP/HTTPS请求绕过证书检测 一.Java实现免证书访问Https请求 创建证书管理器类 import java.security.cert.CertificateExcepti ...
- linux下的C++多线程
原文链接:http://blog.csdn.net/lee1054908698/article/details/54633056 本随笔作为多线程笔记使用,内容完全照搬原博 多线程是多任务处理的一种特 ...