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    9
2 AlwaysAK 5 883 12
3 Fighter 5 883 9
4 RpRpRp 1 75 1
4 SoyOnceMore 1 75 1
6 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 zhi
for(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;
}

Programming Contest Ranking(题解)的更多相关文章

  1. M-SOLUTIONS Programming Contest 2020 题解

    M-SOLUTIONS Programming Contest 2020 题解 目录 M-SOLUTIONS Programming Contest 2020 题解 A - Kyu in AtCode ...

  2. atcoder Keyence Programming Contest 2020 题解

    比赛地址 A 题意:给一个\(n*m\)的初始为白色的矩阵,一次操作可以将一行或一列染成 黑色,问至少染出\(k\)个黑点的最少操作次数. \(n\),\(m\)<=100,\(k\)<= ...

  3. 【AtCoder】Dwango Programming Contest V题解

    A - Thumbnail 题意简述:给出N个数,找出N个数中和这N个数平均值绝对值最小的数 根据题意写代码即可= = #include <bits/stdc++.h> #define f ...

  4. 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) ...

  5. Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】

    F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standar ...

  6. KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解

    KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解 哦淦我已经菜到被ABC吊打了. A - Century 首先把当前年 ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  8. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

  9. 2016 Sichuan Province Programming Contest

    2016 Sichuan Province Programming Contest 代码 2016 Sichuan Province Programming Contest A. Nearest Ne ...

随机推荐

  1. fedora中使用 mariadb数据库建库和建表-- mariadb数据库服务无法启动?

    /proc(进程, 过程等含义) 文件系统是一个虚拟文件系统,通过它可以使用一种新的方法在 Linux® 内核空间(内核)和用户空间(用户)之间进行通信.在 /proc 文件系统中,我们可以将对虚拟文 ...

  2. shell:遍历目录和子目录的所有文件及匹配文件内容到日志

    过滤文件内网 #!/bin/bash function getdir(){ ` do dir_or_file=$"/"$element if [ -d $dir_or_file ] ...

  3. java 关于wait,notify和notifyAll

    public synchronized void hurt() { //... this.wait(); //... } public synchronized void recover() { // ...

  4. js与jquery对象的互转

    //dom对象 var odiv = document.getElementById('box'); //dom对象转化成JQ对象, 在通过原生的方法获取到元素后,给它加上$() //$(odiv). ...

  5. UVa 11584 划分成回文串

    https://vjudge.net/problem/UVA-11584 题意: 给出一串字符,把它划分成尽量少的回文串. 思路: 用d[i]表示划分到i时所能划分的最小个数,转移方程为d[i]=mi ...

  6. UVa 11093 环形跑道(模拟)

    https://vjudge.net/problem/UVA-11093 题意:环形跑道上有n个加油站,编号为1~n.第i个加油站可以加油pi加仑,从加油站i开到下一站需要qi加仑汽油.输出最小的起点 ...

  7. UVa 1411 Ants(分治)

    https://vjudge.net/problem/UVA-1411 题意:n只蚂蚁和n颗苹果树,一一配对并且不能交叉. 思路:这就是巨人与鬼的问题.用分治法就行了. #include<ios ...

  8. Oncomine: 一个肿瘤相关基因研究的数据库--转载

    如果你获得了一个肿瘤差异表达基因,想研究其是否可作为某种肿瘤的潜在标志物和靶点,又怕做实验会得到阴性结果,浪费时间和金钱,这时候你就应该想到Oncomine数据库了(www.oncomine.org) ...

  9. Spring 事物机制总结

    Spring两种事物处理机制,一是声明式事务,二是编程式事务 声明式事物 1)Spring的声明式事务管理在底层是建立在AOP的基础之上的.其本质是对方法前后进行拦截,然后在目标方法开始之前创建或者加 ...

  10. Java并发编程:Callable、Future和FutureTask(转)

    Java并发编程:Callable.Future和FutureTask 在前面的文章中我们讲述了创建线程的2种方式,一种是直接继承Thread,另外一种就是实现Runnable接口. 这2种方式都有一 ...