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的更多相关文章

  1. POJ 2379 ACM Rank Table(排序)

    题很水,数据注意一下四点即可: 1.有些team会在一道题AC了之后还提交,这个时候只需要算第一次ac的时间以及这之前的wa,之后的全部忽略.2.如果一道题没有ac,那么在计算时间时不应该加上它的wa ...

  2. 【HDOJ】5096 ACM Rank

    Treap+set仿函数重定义.每当ac一道题目时,相当于对总时间减去一个大数. /* 5096 */ #include <iostream> #include <string> ...

  3. HDU - 5096 ACM Rank (Treap)

    平衡树的题,Treap破之,比较难搞的出现相同题数罚时的情况,解决方法是在每个结点用一个set, 保证结点值的时候可以把题数和罚时保存到一个int里,令v = n*MaxPenaltySum-pena ...

  4. HNUST-1148 ACM ranking rules(简单模拟)

    1148: ACM ranking rules 时间限制: 1 Sec  内存限制: 128 MB提交: 16  解决: 12[提交][状态][讨论版] 题目描述 ACM contests, like ...

  5. HAWQ技术解析(八) —— 大表分区

    一.HAWQ中的分区表        与大多数关系数据库一样,HAWQ也支持分区表.这里所说的分区表是指HAWQ的内部分区表,外部分区表在后面"外部数据"篇讨论. 在数据仓库应用中 ...

  6. 用HAWQ轻松取代传统数据仓库(八) —— 大表分区

    一.HAWQ中的分区表        与大多数关系数据库一样,HAWQ也支持分区表.这里所说的分区表是指HAWQ的内部分区表,外部分区表在后面“外部数据”篇讨论.在数据仓库应用中,事 实表通常有非常多 ...

  7. Flask开发成语接龙游戏,闲来无事手机玩玩自己写的游戏吧!

    英语单词学习应用 周五发布的文章Flask开发天气查询软件,带你掌握pipenv的使用与手机Termux下的部署发布后,看到喜欢的人比较多.本来周末打算照着扇贝/极光单词,写一个英语单词自测工具.但苦 ...

  8. ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线

    hdu 1811 Rank of Tetris Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  9. 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 ...

随机推荐

  1. CentOS7下FTP的安装与配置

    1.安装vsftpd 1 [root@localhost modules]# yum install -y vsftpd 2.编辑ftp配置文件 1 [root@localhost modules]# ...

  2. 使用Buildozer部署Kivy到移动设备上

    在安装好Buildozer软件之后,我们在包含main.py的文件夹下运行buildozer init这个命令,然后我们就会看到在该文件夹下有一个buildozer.spec这个文件,这个文件主要是用 ...

  3. 基于CentOS搭建VNC远程桌面服务

    系统要求:CentOS 7.2 64 位操作系统 安装.启动 VNC VNC 远程桌面原理 名词解释: Xorg:在 Linux 用户中非常流行,已经成为图形用户程序的必备条件,所以大部分发行版都提供 ...

  4. Golang select

    Golang下select的功能和Linux IO复用中的select, poll, epoll相似,是监听 channel 操作,当 channel 操作发生时,触发相应的动作. package m ...

  5. OpenCV 学习笔记 07 目标检测与识别

    目标检测与识别是计算机视觉中最常见的挑战之一.属于高级主题. 本章节将扩展目标检测的概念,首先探讨人脸识别技术,然后将该技术应用到显示生活中的各种目标检测. 1 目标检测与识别技术 为了与OpenCV ...

  6. php http请求封装

    /** * 发送HTTP请求方法,目前只支持CURL发送请求 * @param string $url 请求URL * @param array $params 请求参数 * @param strin ...

  7. git checkout -b mybranch和git checkout mybranch

      创建分支: $ git branch mybranch切换分支: $ git checkout mybranch创建并切换分支: $ git checkout -b mybranch更新maste ...

  8. SNF快速开发平台MVC-单据状态水印

    1.   单据状态水印 1.1.      效果展示 1.2.      调用说明 与easyui的调用方式类似,可以在js中调用,也可以在html中写好所有属性,直接渲染. 如下,在html中写好所 ...

  9. 1.揭开消息中间件RabbitMQ的神秘面纱

    当你看到这篇博文的时候,相信你至少已经知道RabbitMQ 是一个非常优秀的消息中间件,它使用专门处理高并发的Erlang 语言编写而成的消息中间件产品. 当然如果你不知道也没关系,读完本篇你将Get ...

  10. Asp.Net WebApi swagger使用教程

    swagger简介 别名:丝袜哥 功能:用于生产api文档 swagger安装 Nuget搜索swagger,然后安装Swashbuckle swagger使用 生成api的xml文档 webapi项 ...