A - ACM Rank Table
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:
Each run is either accepted or rejected.
The problem is considered solved by the team, if one of the runs submitted for it is accepted.
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.
The total time is the sum of the time consumed for each problem solved.
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.
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.
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
Input contains integer numbers C N, followed by N quartets of integes 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
Output must contain C integers -- team numbers sorted by rank.
Sample Input
3 3
1 2 3000 0
1 2 3100 1
2 1 4200 1
Sample Output
2 1 3
排序,注意输入不是按时间输入的,先储存然后排序,在操作
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(a,b) memset((a),(b),sizeof(a))
#include<vector>
typedef long long ll;
typedef double db;
const ll mod=1e9+7;
using namespace std;
const double pi=acos(-1.0);
struct q
{
int score[1005];
int num;
int sum;
int temp[1005];
}a[1005];
struct qq
{
int c,p,t,r;
}cz[1005];
void solve(int c,int p,int t,int r)
{
if(a[c].temp [p]==0)//如果没过
{
if(r)
{
a[c].temp[p] =1;
a[c].num++;
a[c].sum+=a[c].score[p]*20*60+t;
}else
a[c].score[p]++; //罚时次数加一
}
}
void sortt(qq cz[1005],int n)
{
for(int i=0;i<n-1;i++)
for(int j=0;j<n-i-1;j++)
{
if(cz[j].t >cz[j+1].t )
{
swap(cz[j].c ,cz[j+1].c );
swap(cz[j].p ,cz[j+1].p );
swap(cz[j].r ,cz[j+1].r );
swap(cz[j].t ,cz[j+1].t );
}
}
}
int main()
{
int n,p,pp,c,t,r;
sf("%d%d",&n,&pp);
for(int i=1;i<=n;i++)
{
mm(a[i].score ,0);
a[i].num =0;
a[i].sum =0;
mm(a[i].temp ,0);
}
for(int i=0;i<pp;i++)//储存操作
sf("%d%d%d%d",&cz[i].c ,&cz[i].p,&cz[i].t,&cz[i].r);
sortt(cz,pp);//对操作进行时间排序
for(int i=0;i<pp;i++)//计算rank
solve(cz[i].c,cz[i].p,cz[i].t,cz[i].r);
int nod[21];
mm(nod,0);
for(int i=1;i<=n;i++)//计算ac的题数的队伍数
nod[a[i].num]++;
int tot=1;
for(int i=20;i>=0;i--)//排序输出
{
for(int j=0;j<nod[i];j++)
{
int max=mod,qq;
for(int j=1;j<=n;j++)
{
if(a[j].num ==i)
{
if(max>a[j].sum)
{
max=a[j].sum;
qq=j;
}
}
}
if(tot==n)
{
pf("%d",qq);
}else
{
pf("%d ",qq);
tot++;
a[qq].num =-1;
}
}
}
return 0;
}
A - ACM Rank Table的更多相关文章
- POJ 2379 ACM Rank Table(排序)
题很水,数据注意一下四点即可: 1.有些team会在一道题AC了之后还提交,这个时候只需要算第一次ac的时间以及这之前的wa,之后的全部忽略.2.如果一道题没有ac,那么在计算时间时不应该加上它的wa ...
- 【HDOJ】5096 ACM Rank
Treap+set仿函数重定义.每当ac一道题目时,相当于对总时间减去一个大数. /* 5096 */ #include <iostream> #include <string> ...
- HDU - 5096 ACM Rank (Treap)
平衡树的题,Treap破之,比较难搞的出现相同题数罚时的情况,解决方法是在每个结点用一个set, 保证结点值的时候可以把题数和罚时保存到一个int里,令v = n*MaxPenaltySum-pena ...
- HNUST-1148 ACM ranking rules(简单模拟)
1148: ACM ranking rules 时间限制: 1 Sec 内存限制: 128 MB提交: 16 解决: 12[提交][状态][讨论版] 题目描述 ACM contests, like ...
- HAWQ技术解析(八) —— 大表分区
一.HAWQ中的分区表 与大多数关系数据库一样,HAWQ也支持分区表.这里所说的分区表是指HAWQ的内部分区表,外部分区表在后面"外部数据"篇讨论. 在数据仓库应用中 ...
- 用HAWQ轻松取代传统数据仓库(八) —— 大表分区
一.HAWQ中的分区表 与大多数关系数据库一样,HAWQ也支持分区表.这里所说的分区表是指HAWQ的内部分区表,外部分区表在后面“外部数据”篇讨论.在数据仓库应用中,事 实表通常有非常多 ...
- Flask开发成语接龙游戏,闲来无事手机玩玩自己写的游戏吧!
英语单词学习应用 周五发布的文章Flask开发天气查询软件,带你掌握pipenv的使用与手机Termux下的部署发布后,看到喜欢的人比较多.本来周末打算照着扇贝/极光单词,写一个英语单词自测工具.但苦 ...
- ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线
hdu 1811 Rank of Tetris Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
- Codeforces Round #289 (Div. 2, ACM ICPC Rules) A. Maximum in Table【递推】
A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- Linux下 $(cd `dirname $0`;pwd)
在命令行状态下单纯执行 $ cd `dirname $0` 是毫无意义的.因为他返回当前路径的".".这个命令写在脚本文件里才有作用,他返回这个脚本文件放置的目录,并可以根据这个目 ...
- web中ajax跨域与同源文章 from 阮一峰
跨域资源共享 CORS 详解 http://www.ruanyifeng.com/blog/2016/04/cors.html //这个是最明白的..建议看看. http://www.ruanyif ...
- 浅谈压缩感知(二十二):压缩感知重构算法之正则化正交匹配追踪(ROMP)
主要内容: ROMP的算法流程 ROMP的MATLAB实现 一维信号的实验与结果 测量数M与重构成功概率关系的实验与结果 一.ROMP的算法流程 正则化正交匹配追踪ROMP算法流程与OMP的最大不同之 ...
- 对actuator的管理端点进行ip白名单限制(springBoot添加filter)
在我们的SpringCloud应用中,我们会引入actuator来进行管理和监控我们的应用 常见的有:http://www.cnblogs.com/yangzhilong/p/8378152.html ...
- 第三部分:Android 应用程序接口指南---第二节:UI---第八章 Toast通知
第8章 Toast通知 Toast通知是在窗口前面弹出的信息.它只占有信息所需要的空间量,并且用户当前的activity仍然是可见的.可互动的.这种通知自动地淡入和淡出,它不接受交互事件.他相当于一种 ...
- python中关于round函数的小坑
这个一直都想写,但是因为这个点比较小,所以一直懒得动手.不过还是补上吧,留着早晚是个祸害. round函数很简单,对浮点数进行近似取值,保留几位小数.比如 >>> round(10. ...
- Selenium Web 自动化 - 项目实战环境准备
Selenium Web 自动化 - 项目实战环境准备 2016-08-29 目录 1 部署TestNG 1.1 安装TestNG 1.2 添加TestNG类库2 部署Maven 2.1 mav ...
- idea svn 不见的问题
问题一: IntelliJ IDEA打开带SVN信息的项目不显示SVN信息,项目右键SVN以及图标还有Changes都不显示解决方法 在VCS菜单中有个开关,叫Enabled Version Cont ...
- anaconda的kernel对jupyter可见
在anaconda的kernel下,安装nb_conda_kernels conda install nb_conda_kernels 参考这篇博客
- CentOS7安装RabbitMQ
1.先安装Erlang rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm 2.安 ...