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极限帆船赛在青岛开赛,这场大赛是技术与体育高度融合的盛会.比赛中,每一个船员将使用各种高新技术,应尽所能,战胜对手.很多人之所以喜欢这样的比赛,是因为帆船比赛是世界上最复杂的一项 ...
随机推荐
- 常用grads函数
GrADS的函数分两类, 一类是对格点/站点数据执行运算的,这一类我们姑且称之为分析函数; 另一类是脚本编程(gs)时使用的, 这后一类我们姑且称之为脚本函数. 第一类分析函数又分为格点分析和站点分析 ...
- ubuntu android studio 编译及运行错误Error retrieving parent for item: No resource found that matches the given name
安装好android studio并且安装其它需要的SDK或组件后,根据向导生成新的项目, 编译或运行时可能会出现下面的错误: Error:Error retrieving parent for it ...
- Java多线程系列 JUC线程池06 线程池原理解析(五)
ScheduledThreadPoolExecutor解析 ScheduledThreadPoolExecutor适用于延时执行,或者周期性执行的任务调度,ScheduledThreadPoolExe ...
- ajax的原理及使用
ajax并非是一门新的技术,而是现有技术的一种新的组合用法,即是结合异步javascript和XML,它是一种创建快速动态网页的技术.其中,异步javascript是相对于同步而言的,同步模式通常称为 ...
- 【leetnode刷题笔记】Maximum Depth of binary tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- 解析centos中Apache、php、mysql 默认安装路径
apache:如果采用RPM包安装,安装路径应在 /etc/httpd目录下apache配置文件:/etc/httpd/conf/httpd.confApache模块路径:/usr/sbin/apac ...
- 【Selenium】Option加载用户配置,Chrom命令行参数
about:version - 显示当前版本 about:memory - 显示本机浏览器内存使用状况 about:plugins - 显示已安装插件 about:histograms - 显示历史记 ...
- FJOI2016 神秘数
题目大意 给定长为$N$一个序列,每次询问一个区间,求最小的不能表示为由区间内若干个(可以是$0$个)数的和的非负整数. 考虑一个可重集合$S$,设抽取$S$中若干个数相加无法得到的最小非负整数为$A ...
- bzoj3595 方伯伯的oj
有$n$个数,一开始是$1~n$,有$m$次操作 1.把编号为$x$的人编号改为$y$,保证$y$没出现过 2.把编号为$x$的人提到第一名 3.把编号为$x$的人怼到最后一名 4.查询排名为$x$的 ...
- webpack打包APP的后端地址处理
PC端我们用webpack打包,只需要写相对路径,发布的时候和后端接口在同一目录下即可. 但是做过APP或者混合开发的同学都知道,APP不需要发布的,如果后端地址还是用相对路径的话,可想而知,调用后端 ...