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. 【Qt5】Windows下配置程序的产品、公司、版权、版本号等详细信息

    在工程的pro文件中加入下面的配置 # 配置图标(仅Windows有效)# 本程序使用两个图标,这样其快捷方式可以有更多选择,也可以给关联文件提供图标选择RC_ICONS += icon1.ico \ ...

  2. Tensorflow 之finetune微调模型方法&&不同层上设置不同的学习率

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

  3. chrome 浏览器的插件权限有多大?

    转自:https://segmentfault.com/q/1010000003777353 1)Chrome插件本身有机制控制,不会无限制的开放很多权限给你2)页面的DOM元素时可以操作的,Chro ...

  4. Mac下打开多个eclipse

    命令行执行: open -n /Eclipse所在路径/Eclipse.app  

  5. 【Android】详解Android Activity

    目录结构: contents structure [+] 创建Activity 如何创建Activity 如何创建快捷图标 如何设置应用程序的名称.图标与Activity的名称.图标不相同 Activ ...

  6. EF+LINQ事物处理

    在使用EF的情况下,怎么进行事务的处理,来减少数据操作时的失误,比如重复插入数据等等这些问题,这都是经常会遇到的一些问题 但是如果是我有多个站点,然后存在同类型的角色去操作同一条数据的同一个字段的话, ...

  7. pycharm开发python利器入门

    内容包含:pycharm学习技巧 Learning tips.PyCharm3.0默认快捷键(翻译的).pycharm常用设置.pycharm环境和路径配置.Pycharm实用拓展功能:pycharm ...

  8. 【Spark 深入学习 01】 Spark是什么鬼?

    经过一段时间的学习和测试,是时候给spark的学习经历做一个总结了,对于spark的了解相对晚了写.春节期间(预计是无大事),本博准备推出20篇左右spark系列原创文章(先把牛吹出去再说) ,尽量将 ...

  9. Python3求解字符串滤值与百元买百鸡算法

    [本文出自天外归云的博客园] 第一题:给你一个字符串,打印出来前后没有空格,单词之间只有一个空格的字符串. 第二题:公鸡3元/只,母鸡4元/只,小鸡1元3只,给你money元一共多少种买法. 普通版解 ...

  10. django 返回 code 405

    return HttpResponse('Invalid Method',status=405)