24B F1 Champions
题目
Formula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following order 25, 18, 15, 12, 10, 8, 6, 4, 2, 1. At the conclusion of the championship the driver with most points is the champion. If there is a tie, champion is the one with most wins (i.e. first places). If a tie still exists, it is chosen the one with most second places, and so on, until there are no more place to use for compare.
Last year another scoring system was proposed but rejected. In it the champion is the one with most wins. If there is tie, champion is the one with most points. If a tie still exists it is proceeded the same way as in the original scoring system, that is comparing number of second, third, forth, and so on, places.
You are given the result of all races during the season and you are to determine the champion according to both scoring systems. It is guaranteed, that both systems will produce unique champion.
The first line contain integer t (1 ≤ t ≤ 20), where t is the number of races. After that all races are described one by one. Every race description start with an integer n (1 ≤ n ≤ 50) on a line of itself, where n is the number of clasified drivers in the given race. After that n lines follow with the classification for the race, each containing the name of a driver. The names of drivers are given in order from the first to the last place. The name of the driver consists of lowercase and uppercase English letters and has length at most 50 characters. Comparing of names should be case-sensetive.
Your output should contain exactly two line. On the first line is the name of the champion according to the original rule, and on the second line the name of the champion according to the alternative rule.
3
3
Hamilton
Vettel
Webber
2
Webber
Vettel
2
Hamilton
Vettel
Vettel
Hamilton
2
7
Prost
Surtees
Nakajima
Schumacher
Button
DeLaRosa
Buemi
8
Alonso
Prost
NinoFarina
JimClark
DeLaRosa
Nakajima
Patrese
Surtees
Prost
Prost
It is not guaranteed that the same drivers participate in all races. For the championship consider every driver that has participated in at least one race. The total number of drivers during the whole season is not more then 50.
题目大意
有许多场比赛,给出每场比赛的排名,有两种计分方式:先计分数再比各排名的数量和先比第一数量再比分数再比其他排名,问两种计分方式的冠军各是谁。
分析
大水题,记录每个人获各名次的数量并给每个人编号,暴力排序即可。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
map<string,int>rank[60];
string name[10010];
map<string,bool>used;
int point[20],champ[10010];
int ok,R;
struct node{
int pl,a;
}rating[10010];
bool cmp(const node &x,const node &y){
return x.a>y.a;
}
inline void check(int le,int ri,int level,int p){
if(le==ri){
if(p)ok=1;
cout<<name[rating[le].pl]<<endl;
return;
}
if(level==2&&p){
R=ri;
return;
}
int i,j,k=0;
for(i=le;i<=ri;i++)
rating[i].a=rank[level][name[rating[i].pl]];
sort(rating+le,rating+ri+le,cmp);
for(i=le;i<=ri;i++)
if(rating[i+1].a!=rating[i].a){
check(le,i,level+1,p);
k=1;
break;
}
if(!k)check(le,ri,level+1,p);
}
int main()
{ int n,m,i,j,k,t,cnt=0;
cin>>t;
for(m=1;m<=t;m++){
cin>>n;
for(i=1;i<=n;i++){
string s;
cin>>s;
if(!used[s]){
used[s]=1;
name[++cnt]=s;
}
rank[i][s]++;
}
}
point[1]=25,
point[2]=18,
point[3]=15,
point[4]=12,
point[5]=10,
point[6]=8,
point[7]=6,
point[8]=4,
point[9]=2,
point[10]=1;
for(i=1;i<=cnt;i++)
for(j=1;j<=10;j++){
rating[i].a+=rank[j][name[i]]*point[j];
rating[i].pl=i;
}
sort(rating+1,rating+cnt+1,cmp);
for(i=1;i<=cnt;i++)
if(rating[i+1].a!=rating[i].a){
check(1,i,1,0);
break;
}
check(1,cnt,1,1);
if(ok)return 0;
for(i=1;i<=cnt;i++)rating[i].a=0;
for(i=1;i<=R;i++){
for(j=1;j<=10;j++){
rating[i].a+=rank[j][name[rating[i].pl]]*point[j];
}
}
sort(rating+1,rating+R+1,cmp);
for(i=1;i<=R;i++)
if(rating[i+1].a!=rating[i].a){
check(1,i,2,0);
break;
}
return 0;
}
24B F1 Champions的更多相关文章
- CodeForces 24B F1 Champions(排序)
B. F1 Champions time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- CF24B F1 Champions 题解
Content 有 \(n\) 场已经进行完的赛车比赛,每场比赛给出前 \(m\) 名的名字.在每场比赛中,前 \(10\) 名的选手分别可以获得 \(25,18,15,12,10,8,6,4,2,1 ...
- Online, Asynchronous Schema Change in F1
F1: A Distributed SQL Database That Scales http://disksing.com/understanding-f1-schema-change ma ...
- VB.NET中Form窗体运行时,按F1进入全屏状态
1.在KeyDown事件中添加: If e.KeyValue = 112 Then Me.WindowState = FormWindowState.Maximized End If 注:1.其中11 ...
- SSIS excel2003文件导入列名显示为F1,F2 - FN
问题现象: 数据源2003版本的EXCEL文件,第一列是空白,数据是从第二列开始的.所以SSIS中用EXCEL数据源倒入这个EXCEL时,所有的列显示不出来,显示的是F1,F2 - FN. 解决方法 ...
- Ubuntu 14 常用“快捷键”,Ctrl + Alt + F1 进入终端,按 Ctrl + Alt + F7 回到界面
Ubuntu中所谓 Super键,就是 Windows建,一般在键盘的 ctrl 和 alt 2个键之间,一个微软窗口的图标. 1.持续按住 Super键,会弹出“键盘快捷键”大全: 2.修改快捷键路 ...
- Delphi按下F1不能出现帮助文档的解决方法
不光是Delphi,Windows里面所有的之所以无法打开.hlp帮助文档的问题都可以使用以下的方法来解决 问题:情况是这样的,不是打不开hlp帮助文档,按F1出现的是Windows的帮助.而Delp ...
- F1 分数
F1 分数会同时考虑精确率和召回率,以便计算新的分数. 可将 F1 分数理解为精确率和召回率的加权平均值,其中 F1 分数的最佳值为 1.最差值为 0: F1 = 2 * (精确率 * 召回率) / ...
- SAP大数据为"海上F1"提供技术支持
“海上F1”的2014极限帆船赛在青岛开赛,这场大赛是技术与体育高度融合的盛会.比赛中,每一个船员将使用各种高新技术,应尽所能,战胜对手.很多人之所以喜欢这样的比赛,是因为帆船比赛是世界上最复杂的一项 ...
随机推荐
- 手机端适配rem代码片段
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Win7.窗口自动滚动回到屏幕
PS:笔记本 ThinkPad E440 1.前提:窗口 的一部分位于在屏幕的外面,此窗口处于激活的状态 操作:鼠标放置在窗口内部,鼠标继续往屏幕外部移动,鼠标没有任何其他事件(只有 MouseMov ...
- zookeeper+dubbo问题
1.java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [ ...
- Django-01
知识预览 Django基本命令 二 路由配置系统(URLconf) 三 编写视图 四 Template 五 数据库与ORM admin的配置 一 什么是web框架? 框架,即framework,特指为 ...
- kaggle 欺诈信用卡预测——不平衡训练样本的处理方法 综合结论就是:随机森林+过采样(直接复制或者smote后,黑白比例1:3 or 1:1)效果比较好!记得在smote前一定要先做标准化!!!其实随机森林对特征是否标准化无感,但是svm和LR就非常非常关键了
先看数据: 特征如下: Time Number of seconds elapsed between each transaction (over two days) numeric V1 No de ...
- 11 Python 文件操作
文件操作基本流程 计算机系统分为:计算机硬件,操作系统,应用程序三部分. 我们用python或其他语言编写的应用程序若想要把数据永久保存下来,必须要保存于硬盘中,这就涉及到应用程序要操作硬件,众所周知 ...
- D. String Game 二分加字符串匹配
题目链接 题目大意:给出字符串str1,再第二行给出字符串str2,第三行给出删除str1中的字符的顺序,用数组a[]存,问最多按第三行的顺序删除str1中的字符剩下的字符串中str2 我们定义l为a ...
- 4_Prototype 原型
#Prototype ``` // 不好的做法 monster ghost demon sorcerer class Spawner { public: virtual ~Spawner() {} ; ...
- 【QT】对Qt项目开发中遇到的问题的总结
1. QMessageBox中文乱码 这里的中文乱码是指只有QMessageBox才出现中文乱码,其他都可以正常使用的情况.有些博客中提到使用QString::fromUtf8()函数, 实测有些情况 ...
- vue 打包去掉console.log
在webpack.prod.conf.js 文件中将设置修改为 先全局找到 UglifyJsPlugin 然后修改为: new UglifyJsPlugin({ uglifyOptions: { ...