Programming Contest Ranking

.

题目描述

Heilongjiang Programming Contest will end successfully! And your task is programming contest ranking.

The following rules rankings:

1. A problem is solved when it is accepted by the judges.

2. Teams are ranked according to the most problems solved;

3. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the accepted run plus 20 penalty minutes for every rejected run for that problem regardless of submittal time. Team(s) who firstly solved the problem will have no penalty in the problem. There is no time consumed for a problem that is not solved.

4. Teams who are the same number of problems solved and the same total time are ranked by the most weighting number of problems solved;The weight of the i-th problem is the floor of N/Ci. where N is the number of all teams, and Ci is the number of teams who solved the i-th problem. The weight of one problem will be 0 if there is no team solved the problem.

输入

The input contains multiple test cases. For each test case,first line contains two integers,N and M,N (1 < N <=200) is the number of all teams,M (6 <= M <=20) is the number of problems;

Then following N lines, there are M+1 items seprated by a space in each.line, corresponding the record of one team . The first item is the name of the team, not exceed 20 letters. Then following M items, each item is:

1. -\-    if the team did not submit for the problem;

2. TT\-  if the team submitted TT times for the problem,but did not solve it.

3. TT\FT if the team submitted TT times for the problem, FT is the time elapsed from the beginning of the contest to the submittal of the accepted.

1 <= TT <= 32, 1 <= FT<=300, Both TT and FT are integer.

输出

Output ranking result in N lines.

The format of each line is:

Rank (width 3)

Name of team (width 20)

Number of problems solved (width 2)

Total time(width 6)

Weighting Number of problems solved (width 4)

Each item above align right, seprated by a space.

样例输入

6 6
Leifeng 8\135 1\20 1\57 5\230 6\- 3\283
Fighter 7\136 1\15 1\42 6\200 5\- 2\270
AlwaysAK 7\156 1\24 1\31 5\202 5\270 4\-
SoyOnceMore 5\- 6\- 3\- 2\75 -\- -\-
RpRpRp 5\- 3\35 10\- -\- -\- -\-
StartAcm 2\- 3\- 3\- 4\- 1\- -\-

样例输出

  1              Leifeng  5    845    92             AlwaysAK  5    883   123              Fighter  5    883    94               RpRpRp  1     75    14          SoyOnceMore  1     75    16             StartAcm  0      0    0

提示

In the sample, though team Leifeng submitted 8 times for problem A, but they firstly solved problem A, so the time consumed of problem A is 135, not 275.

题解
模拟oj排名,每个题的信息TT/FT中tt表示提交次数,FT表示AC提交时间,然后输出排行榜
解题思路:
我用的是两个结构体,一个表示每个题的信息,另一个结构题表示的是每一个人的信息,然后计算ac题数,和错误时间,需要注意的是首杀无罚时!!!!,还有就是权重的计算,每一个题的权重==总参加人数/a过的总人数;之后就是排序,首先按照题数降序排列,题数一样就按照时间升序排列,如果时间也一样,那就按照这个人的权重和降序排列,如果还一样了(三生有缘啊!!!!)按照姓名的字典序升序排列(sort万岁!!!)~~~
代码如下
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;int n,m;
struct timu{int zhuang;int wa;int time;
};
struct date {char name[50];int sumtime;int quan;int sumt;struct timu pro[100];
}line[1000];
void ff(int x,int p,char ch[])
{int i,j;int y=0;int m=0;for(i=0;ch[i]!='\0';i++){if(ch[i]=='\\'){line[x].pro[p].wa=m;m=0;}else if(ch[i]=='-'){line[x].pro[p].zhuang=0;line[x].pro[p].time=0;return ;}else{m=m*10+ch[i]-'0';}}line[x].pro[p].zhuang=1;line[x].pro[p].time=m;//(line[x].pro[p].wa-1)*20//printf("==>> %s %d---%d\n",ch,line[x].pro[p].wa,line[x].pro[p].time);
}
int cmp (date a,date b)
{if(a.sumt!=b.sumt)return a.sumt>b.sumt;else if(a.sumtime!=b.sumtime)return a.sumtime<b.sumtime;else if(a.quan!=b.quan)return a.quan>b.quan;else return strcmp(a.name,b.name)<0;
}
int main()
{int vis[100];int i,j,sum,num,minn,k;char ch[100];while(~scanf("%d %d",&n,&m)){memset(line,0,sizeof(line));memset(vis,0,sizeof(vis));for(i=0;i<n;i++){scanf("%s",line[i].name);for(j=0;j<m;j++){scanf("%s",ch);ff(i,j,ch);}}for(j=0;j<m;j++){k=-1;minn=inf;for(i=0;i<n;i++){if(line[i].pro[j].zhuang)vis[j]++;if(line[i].pro[j].zhuang!=0&&line[i].pro[j].time<minn){minn=line[i].pro[j].time;k=i;}}if(k!=-1){line[k].pro[j].wa=1;}}//geng xin quan zhifor(i=0;i<n;i++){for(j=0;j<m;j++){if(line[i].pro[j].zhuang){if(vis[j])line[i].quan+=n/vis[j];line[i].sumt++;line[i].sumtime+=line[i].pro[j].time+(line[i].pro[j].wa-1)*20;}}}k=0;sort(line,line+n,cmp);for(i=0;i<n;i++){if(i!=0&&line[i].sumt==line[i-1].sumt&&line[i].sumtime==line[i-1].sumtime&&line[i].quan==line[i-1].quan){printf("%3d",k+1);}else {printf("%3d",i+1);k=i;}printf(" %20s",line[i].name);printf(" %2d %6d %4d\n",line[i].sumt,line[i].sumtime,line[i].quan);}}return 0;
}

转载于:https://www.cnblogs.com/lanaiwanqi/p/10445742.html

Programming Contest Ranking(题解)相关推荐

  1. 2021 Jiangsu Collegiate Programming Contest部分题解

    2021 Jiangsu Collegiate Programming Contest 目录 A. Spring Couplets C. Magical Rearrangement I. Fake W ...

  2. The 16th Heilongjiang Provincial Collegiate Programming Contest部分题解

    The 16th Heilongjiang Provincial Collegiate Programming Contest 目录 D - Doin' Time 题目思路 题目代码 F - Func ...

  3. Nordic Collegiate Programming Contest 2017 题解

    前几天打了一场外国人的比赛,感觉那边的题目质量还是很好的,区分度很鲜明,题目没有国内的难,坑点比较少,比较注重思维,基础算法. B题: Best Relay Team Picture by Ferna ...

  4. The 15th Chinese Northeast Collegiate Programming Contest部分题解

    The 15th Chinese Northeast Collegiate Programming Contest 目录 E. Easy Math Problem 题目思路 题目代码 I. Takea ...

  5. The 18th Zhejiang Provincial Collegiate Programming Contest部分题解(A,C,G,J,L,M)

    A. League of Legends Codeforces 题意 签到题 C. Cube Codeforces 题意 给出 888 个点,判断这 888 个点是否组成一个正方体. 题解 888 个 ...

  6. 2019, XII Samara Regional Intercollegiate Programming Contest 全部题解

    英语巨烂的我,把两个签到题读成了不可写题-感觉给我一个中文题面,有机会ak- A. Rooms and Passages 题意:有 n + 1个点在一排,有 n 条边连接,依次求点 i 往 点 n 的 ...

  7. The 14-th BIT Campus Programming Contest(部分题解)

    A. 两只脑斧 time limit per test1.0 s memory limit per test256 MB inputstandard input outputstandard outp ...

  8. The 15th UESTC Programming Contest Preliminary K - Kidd1ng Me? cdoj1565

    地址:http://acm.uestc.edu.cn/#/problem/show/1565 题目: Kidd1ng Me? Time Limit: 3000/1000MS (Java/Others) ...

  9. 2011 Heilongjiang collegiate programming contest 【(7+1)/10】 [补完]

    题目链接: [CDOJ] https://vjudge.net/contest/170394#overview [hrbust1395~1402(中文题面哦!) ] http://acm.hrbust ...

最新文章

  1. 科研文献|根相关真菌群落反映了亚热带森林中宿主的空间共生模式
  2. 铜陵信息化建设和智慧城市发展成果惠及百姓
  3. QStyleOptionGraphicsItem实现自绘按钮悬浮按下状态
  4. vue样式中背景图片路径_vue打包css文件中背景图片的路径问题
  5. 吴恩达深度学习 —— 4.5 搭建深层神经网络块
  6. node html响应头,nodejs 中http请求头,响应头
  7. 输出文件名,用i迭代的时候的方法
  8. LINUX C正确遍历environ
  9. 寄存器是什么 有什么作用
  10. ubuntu硬盘序列号怎么查询_如何在Linux中查找硬盘的详细信息?
  11. 打开.class文件
  12. Python实现最小二乘法曲线拟合
  13. [C++系列] 66. 超详解C++阶段性总结思维导图
  14. 火焰传感器的简单使用
  15. Android Studio基础输入文本框EditText
  16. C# DateTime Subtract
  17. 计算机的击键方法教学教案,2.2 敲击键盘 教案
  18. 2018-2019-2 20165205 网络对抗技术 Exp7 网络欺诈防范
  19. 怎样翻译文本?这三种翻译方法我经常使用
  20. 工具软件界的奇葩公司-Ashampoo

热门文章

  1. 朱嘉明:产业周期、科技周期与金融周期的失衡
  2. 通过Debug命令行清除BIOS Setup密码
  3. SpecMPI2007 benchmark
  4. ChinaSoft 论坛巡礼 | 编译器与编程语言
  5. 多数据源的配置和使用
  6. SQL语句的书写顺序和解析顺序
  7. 高考状元、奥赛金牌,清华姚班00后新生来了
  8. Python绘制世界疫情地图
  9. nginx配置日志记录问题
  10. 毕业设计 基于大数据的旅游数据分析与可视化系统