zoukankan      html  css  js  c++  java
  • POJ2379 ACM Rank Table 模拟题

    ACM Rank Table
    Time Limit: 1000MS Memory Limit: 65536K
    Total Submissions: 2979 Accepted: 764

    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 3
    1 2 3000 0
    1 2 3100 1
    2 1 4200 1

    Sample Output

    2 1 3

      模拟题,注意数据中的时间是以秒为计数单位,罚时是20分钟,所以要乘以60秒钟。还有一点就是可能会出现多次提交同一个题目,就算那道题已经AC了,无聊啊,而且还有可能先告诉你
    某队在后面的时间错误提交,而后面的数据有告诉你前面他已经AC了这道题目。
      
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    struct T
    {
    	int team, pnum, time;
    	int pwrong[21];
    }t[1005];
    
    struct D
    {
    	int c, p, ti,r; 
    }d[1005];
    
    int C, N;
    
    int cmp( const void *a, const void *b )
    {
    	struct T *t1= ( struct T *)a, *t2= ( struct T * )b; 
    	if( t1-> pnum!= t2-> pnum )
    	{
    		return t2-> pnum- t1-> pnum;
    	}
    	else if( t1-> time!= t2-> time )
    	{
    		return t1-> time- t2-> time;
    	}
    	else
    	{
    		return t1-> team- t2-> team;
    	}
    }
    
    int cmp2( const void *a, const void *b )
    {
    	struct D *d1= ( struct D * )a, *d2= ( struct D * )b;
    	return d1-> ti- d2-> ti;
    }
    
    int main(  )
    {
    	while( scanf( "%d %d", &C, &N )!= EOF )
    	{
    		memset( t, 0, sizeof( t[0] )* C );
    		for( int i= 1; i<= C; ++i )
    		{
    			t[i]. team= i;
    		}
    		for( int i= 0; i< N; ++i )
    		{
    			scanf( "%d %d %d %d", &d[i]. c, &d[i]. p, &d[i]. ti, &d[i]. r );
    		}
    		qsort( d, N, sizeof( d[0] ), cmp2 );
    		for( int i= 0; i< N; ++i )
    		{
    			int c= d[i]. c, p= d[i]. p, ti= d[i]. ti, r= d[i]. r;
    			if( r== 1 )
    			{	
    				if( t[c]. pwrong[p]!= -1 )
    				{
    					t[c]. time+= ( ti+ t[c]. pwrong[p]* 20* 60 );
    					t[c]. pnum++;
    				}
    				t[c]. pwrong[p]= -1;
    			}
    			else
    			{
    				if( t[c]. pwrong[p]!= -1 )
    				{
    					t[c]. pwrong[p]++;
    				}
    			}
    		}
    		qsort( t+ 1, C, sizeof( t[0] ), cmp );
    		for( int i= 1; i<= C; ++i )
    		{
    			printf( i== 1? "%d": " %d", t[i]. team );
    		}
    		puts( "" );
    	}
    	return 0;
    }
    

    代码如下:

  • 相关阅读:
    微信小程序开发--页面之间的跳转
    iOS基础UI控件介绍-Swift版
    iOS技术栈-Swift版
    SpringBoot实战(四)获取接口请求中的参数(@PathVariable,@RequestParam,@RequestBody)
    SpringBoot实战(三)代码热部署
    SpringBoot实战(二)Restful风格API接口
    SpringBoot实战(一)HelloWorld
    Spring Boot浅谈(是什么/能干什么/优点和不足)
    CentOS的基本设置界面
    虚拟机VM安装Linux系统CentOS7
  • 原文地址:https://www.cnblogs.com/Lyush/p/2114254.html
Copyright © 2011-2022 走看看