POJ

来源:互联网 发布:钢筋笼计算软件 编辑:程序博客网 时间:2024/06/18 03:47
ACM Rank Table
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4996 Accepted: 1299

Description

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:
  1. Each run is either accepted or rejected.
  2. The problem is considered solved by the team, if one of the runs submitted for it is accepted.
  3. 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.
  4. The total time is the sum of the time consumed for each problem solved.
  5. 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.
  6. 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.
  7. 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 31 2 3000 01 2 3100 12 1 4200 1

Sample Output

2 1 3 麻烦了点,但还是一样的水。。
#include<iostream>#include<cstring>#include<algorithm>using namespace std;struct A1{    int TEAM,ToW[21],wrong[21],time,T;} team[1002];struct A2{    int team,problem,time,TF;} in[1008];bool compare1(A2 a,A2 b);bool compare2(A1 a,A1 b);int main(){    int n,m;    while(cin>>m>>n!=NULL)    {        memset(team,0,sizeof(team));        for(int i=1; i<=m; i++)            team[i].TEAM=i;        for(int i=0; i<n; i++)            cin>>in[i].team>>in[i].problem>>in[i].time>>in[i].TF;        sort(in,in+n,compare1);        for(int i=0; i<n; i++)            if(team[in[i].team].ToW[in[i].problem]==0)                if(in[i].TF==0)                    team[in[i].team].wrong[in[i].problem]++;                else                {                    team[in[i].team].ToW[in[i].problem]=1;                    team[in[i].team].T++;                    team[in[i].team].time+=team[in[i].team].wrong[in[i].problem]*1200+in[i].time;                }        sort(team+1,team+m+1,compare2);        cout<<team[1].TEAM;        for(int i=2; i<=m; i++)            cout<<' '<<team[i].TEAM;        cout<<endl;    }    return 0;}bool compare1(A2 a,A2 b){    return a.time<b.time;}bool compare2(A1 a,A1 b){    if(a.T!=b.T)        return a.T>b.T;    if(a.time!=b.time)        return a.time<b.time;    return a.TEAM<b.TEAM;}


原创粉丝点击