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. Tensorflow 之finetune微调模型方法&&不同层上设置不同的学习率

    在不同层上设置不同的学习率,fine-tuning https://github.com/dgurkaynak/tensorflow-cnn-finetune ConvNets: AlexNet VG ...

  2. oracle11g-linux 归档处理

    在使用oracle时突然登录不上去了提示:ORA-00257:archiver error.Connect internal only,until freed. 查遍很多资料,都指向“归档日志空间不足 ...

  3. .NET 开源开发项目【翻译】

    原文地址 本文列出了 .NET 开源开发项目(open source developer projects).意在包括对开发过程的所有方面有所帮组的项目.对于消费项目(consumer project ...

  4. springcloud学习笔记(五)Spring Cloud Actuator

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

  5. ubuntu 登陆信息打印 -- motd

    新需求需要改变 Ubuntu 启动时的登录信息打印,根据搜索到的资料,找到了这里: luo[~]ssh luo@192.168.100.233 Press ^@ (C-Space) to enter ...

  6. SQL 中的多条件查询

    在应用程序开发中,多条件查询是个经常遇到的情况,最简单最麻烦的方法是把所有的可能情况都考虑到,但是无疑是繁琐的,而且很容易漏掉可能的情形,下面是SQL语句实现多条件查询的情况 select * fro ...

  7. PureFTP被动端口设置

    修改Pureftp的配置文件把 # PassivePortRange          30000 50000 把前面的#删除 重启pureftpd 注意把被动端口防火墙例外 如果是阿里云主机 安全规 ...

  8. Atitit 提升进度的大原则与方法  高层方法  attilax总结

    Atitit 提升进度的大原则与方法  高层方法  attilax总结 生产力的提升点 1.1. 管理,管理的发展发展非常缓慢,1 1.2. 方法论(前后分离,dsl等)1 1.3. 工具( 工具链 ...

  9. [svc]runinit管理多进程

    runinit启动小程序测试 与Supervisord类似的工具包括monit, daemontools和runit. 我还发现个神器,专门针对单容器启动多进程的神器s6: https://githu ...

  10. python(60):configparser 函数,配置文件

    ConfigParser模块学习 介绍 ConfigParser模块在python中是用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(section),每 ...