1148: ACM ranking rules

时间限制: 1 Sec  内存限制: 128 MB
提交: 16  解决: 12
[提交][状态][讨论版]

题目描述

ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:

1.         Each run is either accepted or rejected.

2.         The problem is considered solved by the team, if one of the runs submitted for it is accepted.

3.         The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submission of the first accepted run for this problem (in minutes) plus 20 minutes for every other run for this problem before the accepted one. For an unsolved problem consumed time is not computed.

4.         The total time is the sum of the time consumed for each problem solved.

5.         Teams are ranked according to the number of solved problems. Teams that solve the same number of problems are ranked by the least total time.

6.         While the time shown is in minutes, the actual time is measured to the precision of 1 second, and the the seconds are taken into account when ranking teams.

7.         Teams with equal rank according to the above rules must be sorted by increasing team number.

Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.

输入

Input contains integer numbers C N, followed by N quartets of integers ci pi ti ri, where ci -- team number, pi -- problem number, ti -- submission time in seconds, ri -- 1, if the run was accepted, 0 otherwise.

1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.

输出

Output must contain C integers -- team numbers sorted by rank.

样例输入

3 3
1 2 3000 0
1 2 3100 1
2 1 4200 1

样例输出

2 1 3

提示

用结构体数组存储各队信息

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std; const int N = + ; int c, n;
struct node{
short _time = , solve = , num;
map<int, int> state;
}Node[N]; int main(){
scanf("%d %d", &c, &n);
for(int i = ; i <= c; i++) Node[i].num = i; int ci, pi, ti, ri;
for(int i = ; i <= n; i++){
scanf("%d %d %d %d", &ci, &pi, &ti, &ri);
auto & mp = Node[ci].state;
if(mp[pi] < ) continue;
if(ri == ) mp[pi]++;
if(ri == ) {
Node[ci]._time += (mp[pi] * * + ti);
mp[pi] = -;
Node[ci].solve++;
}
}
auto cmp = [](const node &x, const node &y) -> bool{
if(x.solve != y.solve) return x.solve > y.solve;
return x._time < y._time;
};
stable_sort(Node + , Node + n + , cmp);
for(int i = ; i <= n; i++){
printf("%d%c", Node[i].num, (i == n)?'\n':' ');
}
}

HNUST-1148 ACM ranking rules(简单模拟)的更多相关文章

  1. (hdu step 8.1.6)士兵队列训练问题(数据结构,简单模拟——第一次每2个去掉1个,第二次每3个去掉1个.知道队伍中的人数&lt;=3,输出剩下的人 )

    题目: 士兵队列训练问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  2. NYOJ 题目77 开灯问题(简单模拟)

    开灯问题 时间限制:3000 ms  |            内存限制:65535 KB 难度:1           描述 有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2 ...

  3. HDU 4772 Zhuge Liang&#39;s Password (简单模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 ...

  4. java web学习总结(二十二) -------------------简单模拟SpringMVC

    在Spring MVC中,将一个普通的java类标注上Controller注解之后,再将类中的方法使用RequestMapping注解标注,那么这个普通的java类就够处理Web请求,示例代码如下: ...

  5. WPF简单模拟QQ登录背景动画

    介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...

  6. Linux 内核 链表 的简单模拟(2)

    接上一篇Linux 内核 链表 的简单模拟(1) 第五章:Linux内核链表的遍历 /** * list_for_each - iterate over a list * @pos: the & ...

  7. Linux 内核 链表 的简单模拟(1)

    第零章:扯扯淡 出一个有意思的题目:用一个宏定义FIND求一个结构体struct里某个变量相对struc的编移量,如 struct student { int a; //FIND(struct stu ...

  8. JavaWeb学习总结(四十九)——简单模拟Sping MVC

    在Spring MVC中,将一个普通的java类标注上Controller注解之后,再将类中的方法使用RequestMapping注解标注,那么这个普通的java类就够处理Web请求,示例代码如下: ...

  9. 简单模拟Hibernate的主要功能实现

    在学习期间接触到Hibernate框架,这是一款非常优秀的O/R映射框架,大大简化了在开发web项目过程中对数据库的操作.这里就简单模拟其底层的实现. /*******代码部分,及其主要注解***** ...

随机推荐

  1. cat:连接文件并打印输出到标准输出设备

    是 concatenate(连接.连续)的简写.cat 命令可以用来显示文本文件的内容,也可以把几个文件内容附加到另一个文件中,即连接合并文件. cat 命令的基本格式如下: [root@localh ...

  2. String Compression

    F. String Compression 利用dp和前缀数组来写 dp[i] 所表示的东西是 字符串 s[0:i] (不包括 s[i])能够压缩的最短长度 bj[i][j] 表示的是字符串 s[i: ...

  3. JIRA7.13版本创建项目:工作流(二)

    工作流 在上一篇文章中,我们新建了一个问题类型,并且增加到问题类型方案里了,同时又关联到我们的这个项目中.那么这些问题我们需要如何设置流程走向来表示问题的处理过程呢?这就需要设定一个流程,并将这个流程 ...

  4. xpath元素定位方法

    XPath 使用路径表达式来选取 XML 文档中的节点或者节点集.这些路径表达式和我们在常规的电脑文件系统中看到的表达式非常相似.XPath 含有超过 100 个内建的函数.这些函数用于字符串值.数值 ...

  5. TCP定时器 之 TIME_WAIT定时器

    概述 在FIN_WAIT_2收到对端发来的FIN,并回复ACK之后,会进入TIME_WAIT状态,此时添加定时器,定时器超时会将tw控制块从ehash和bhash中删除,并且释放tw控制块: 启动定时 ...

  6. 第七周课程总结&实验报告五

    实验四 类的继承 实验目的 理解抽象类与接口的使用: 了解包的作用,掌握包的设计方法. 实验要求 掌握使用抽象类的方法. 掌握使用系统接口的技术和创建自定义接口的方法. 了解 Java 系统包的结构. ...

  7. 【Spark机器学习速成宝典】基础篇01Windows下spark开发环境搭建+sbt+idea(Scala版)

    注意: spark用2.1.1 scala用2.11.11 材料准备 spark安装包 JDK 8 IDEA开发工具 scala 2.11.8 (注:spark2.1.0环境于scala2.11环境开 ...

  8. SpringBoot整合Mybatis,并实现事务控制

    SpringBoot整合Mybatis,并实现事务控制 1. 在pom文件里添加相关maven文件 <parent> <groupId>org.springframework. ...

  9. 2.进行model和log的路径创建

    第一步:使用datetime.strftime(datetime.now(), '%Y%m%d-%H%M%S') 用于生成当前时间 第二步: 使用os.path.join() 将文件的路径与subdi ...

  10. leetcode 83删除排序链表中的重复元素

    /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ...