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. logback身份证脱敏

    logback身份证脱敏 学习了:https://shift-alt-ctrl.iteye.com/blog/2425469 https://blog.csdn.net/fywfengyanwei/a ...

  2. MDX Cookbook 08 - 基于集合上的迭代递归

    递归的应用有时是非常重要的,特别在迭代一个集合的时候.为什么这么说呢?原因在于迭代在MDX中的使用是基于集合函数的,像 GENERATE() 它们都需要遍历整个集合.但是如果这个集合非常的庞大,我们仅 ...

  3. 【C#】C#对Excel表的操作

    目录结构: contents structure [+] Microsoft.Office.Interop.Excel.Application Aspose.cell插件 1.Microsoft.Of ...

  4. Django Web开发学习笔记(5)

    第五部分 Model 层 创建一个app工程.app和project的区别引用DjangoBook的说法是: 一个project包含很多个Django app以及对它们的配置. 技术上,project ...

  5. android4.3 截屏功能的尝试与失败分析

    1.背景 上一篇讲了在源码中捕获到了android手机的截屏函数(同时按下电源键与音量减,详情http://blog.csdn.net/buptgshengod/article/details/199 ...

  6. SNF快速开发平台MVC-审核流,审核完成后会给下一个审核人发邮件,下一个审核人可以不登录系统,在邮件里进行审核处理

    审核流设计和使用参考以下资料: 审核流设计 http://www.cnblogs.com/spring_wang/p/4874531.html 审核流实例 http://www.cnblogs.com ...

  7. QT和MFC的差别

    QT和MFC的差别 在使用MFC之前就已经使用Qt这个事实可能影响了我的客观性. (MFC效率较高,但大量的Windows API和消息机制使得其较难理解,不易用:QT封装较好,易用且跨平台,但效率较 ...

  8. Atitit 列出wifi热点以及连接

    Atitit 列出wifi热点以及连接 配置命令 >netsh wlan  /?1 显示已经有的配置netsh wlan show profiles1 C:\Users\Administrato ...

  9. IIS7 配置 PHP5.6

    环境: 操作系统:Win7 & 10 (x64) 中文专业版 PHP       :V5.6 首先添加IIS. 控制面板-〉程序-〉打开或关闭Windows功能 1. 勾选"Inte ...

  10. Android开发(二十三)——Application

    参考: [1] Android中Application类用法.http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.htm ...