zoj1444 Final Standings解题报告

题目大意:本题是模拟ACM比赛中的排名规则,根据所给的信息来输出一个Final Standings(最后的榜单)!!

规则如下:

1,排名按照AC的题数降序排列;

2,AC了同样的题数,那么就按照解题的Total penalty time升序排列(花的时间少肯定排前)

3,如果排名一样(意思是AC题数和总时间都一样),就按照队名的字典序升序排列,但是注意which should be case-insensitive   
(不分大小写)

另外:

1,一个题目被solved  仅当获得AC

2,一个题目的Penalty time 
 是第一次AC时候的elapsed time (就是从开始到AC的那个时间,也就是输入案例每一行的第一个数)和其他判断时候罚时的总和(每次不AC罚时20)

3,一个队伍的Total penalty
time 是所有题目中的被solved时的Penalty time

4,只有一个队伍至少AC 1个题目时才能被输出到榜单上!

Sample Input

3

30 Fatmouse 1 WA

32 Killer 2 AC

39 Turing 3 RE

56 Fatmouse 2 CE

63 Turing 3 AC

77 Killer 1 PE

79 Killer 1 AC

83 ZzZzZ 3 AC

89 Fatmouse 3 OLE

89 Chenyue 3 AC

Sample Output

由于网页上案例好像排列不方便看,这里贴出我的测试输出文档截图

需要注意的地方:

想不到学ACM这么久,我还是通过这个题目才了解到ACM比赛中的具体成绩规则!!!!

一个题目只有当AC之后,它的罚时才会被加到总时间里面去,不然罚时会被忽略!!!!

------------------------------------------------------------------------------------------------------------------------------------

解决方法:

关于队名,这里用一个map映射,每个队伍用struct保存

struct 里面包括

int AC;//AC题数

int tol_time;//总时间

string team_name;//队名

int problem[PRO_MAX];//初始0,每次不AC就-20表示一次没过罚时,AC了才把所有的时间加到tol_time,并且赋值1

bool operator<(const team_node& T)const

{

if(T.AC != AC) return AC > T.AC;//AC数降序

else if(tol_time != T.tol_time) return tol_time < T.tol_time;//总时间升序

else return mycmp(team_name,T.team_name);//按名字字典序比较

}

------------------------------------------------------------------------------------------------------------------------------------------

代码:

#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define TEAM_MAX 10005
#define PRO_MAX 105

int team_sum;//总的队数

bool mycmp(string a,string b)//统一换成大写比较
{
    for(int i = 0; i < a.length(); i ++) if(a[i] > ‘Z‘) a[i] -= 32;
    for(int i = 0; i < b.length(); i ++) if(b[i] > ‘Z‘) b[i] -= 32;
    return a<b;
}

struct team_node
{
    int AC;
    int tol_time;
    string team_name;
    int problem[PRO_MAX];//初始0,每次不AC就-20表示一次没过罚时,AC了才把所有的时间加到tol_time,并且赋值1

    bool operator<(const team_node& T)const
    {
        if(T.AC != AC) return AC > T.AC;//AC数降序
        else if(tol_time != T.tol_time) return tol_time < T.tol_time;//总时间升序
        else return mycmp(team_name,T.team_name);//按名字字典序比较
    }
}TEAM[TEAM_MAX];

void print()
{
    int rank = 1;
    if(TEAM[0].AC == 0) return ;
    printf("%-10d%-30s%-10d%d\n",rank,TEAM[0].team_name.c_str(),TEAM[0].AC,TEAM[0].tol_time);

    for(int i = 1; i < team_sum; i ++)
    {
        rank++;
        if(TEAM[i].AC == 0) return ;
        if(TEAM[i].AC == TEAM[i-1].AC && TEAM[i].tol_time == TEAM[i-1].tol_time)//解决同rank输出情况
        {
            printf("          %-30s%-10d%d\n",TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time);
        }
        else
            printf("%-10d%-30s%-10d%d\n",rank,TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);

    int N;
    int time,pro;
    string team,judge;

    map<string,int>m;

    team_sum = 0;//总队数初始0
    cin>>N;
    while(cin>>time>>team>>pro>>judge)
    {
        int id;//队伍id
        if(m.find(team) == m.end())
        {
            id = team_sum++;
            m[team] = id;//映射
            TEAM[id].AC = TEAM[id].tol_time = 0;
            TEAM[id].team_name = team;
            memset(TEAM[id].problem,0,sizeof(TEAM[id].problem));
        }
        else id = (*m.find(team)).second;

        if(judge == "AC" && TEAM[id].problem[pro] != 1)
        {
            TEAM[id].tol_time += time - TEAM[id].problem[pro];
            TEAM[id].AC ++;
            TEAM[id].problem[pro] = 1;//表示已经AC
        }
        else
        {
            if(TEAM[id].problem[pro] == 1) continue;
            TEAM[id].problem[pro] -= 20;
        }
    }

    sort(TEAM,TEAM+team_sum);
    print();

    return 0;
}

zoj1444 Final Standings解题报告

时间: 2024-11-11 23:16:07

zoj1444 Final Standings解题报告的相关文章

10.30 NFLS-NOIP模拟赛 解题报告

总结:今天去了NOIP模拟赛,其实是几道USACO的经典的题目,第一题和最后一题都有思路,第二题是我一开始写了个spfa,写了一半中途发现应该是矩阵乘法,然后没做完,然后就没有然后了!第二题的暴力都没码QAQ 现在我来写解题报告了,有点饿了QAQ.. 第一题 题目 1: 架设电话线 [Jeffrey Wang, 2007] 最近,Farmer John的奶牛们越来越不满于牛棚里一塌糊涂的电话服务,于 是,她们要求FJ把那些老旧的电话线换成性能更好的新电话线.新的电话线架设 在已有的N(2 <=

hdu 4932 Miaomiao&#39;s Geometry 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4932 题目意思:给出 n 个点你,需要找出最长的线段来覆盖所有的点.这个最长线段需要满足两个条件:(1)每个点是某条线段的左端点或右端点   (2)任意两条线段之间的重叠部分的长度为0.(一个点重叠默认长度为0,即[1,2] , [2, 3] 视为合法).还有一点我来补充吧,就是这个最大长度是固定的,看第3组测试数据  1 9 100 10,[-7,1] , [1,9] , [10,18] , [1

IOI&#39;96 Magic Square解题报告

IOI‘96 Magic Square(魔版) 题目由JerryXie翻译. Magic Square(msqaure.cpp/c/pas) [问题描述] 在魔方的成功之后,卢比克先生发明了它的二维版本,叫做魔版.它是一个由八个方块组成的表格. 在本题中我们认为每一个方块都有不同的颜色,这些颜色将会用1~8共8个整数表示.一个表格的状态将会以一个由颜色组成的序列表示,顺序是从表格左上角沿顺时针方向给出.比如上面这个表格,序列为(1,2,3,4,5,6,7,8),这被称作初始状态. 魔版有三种基本

LeetCode解题报告:LRU Cache

LRU Cache Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise retu

USACO Section2.2 Party Lamps 解题报告 【icedream61】

lamps解题报告------------------------------------------------------------------------------------------------------------------------------------------------[题目] N个灯,编号1~N.有4个开关,和C次改变某个开关状态的机会,试问最终所有灯的亮灭情况可能有哪些? 一号开关:改变所有灯的状态. 二号开关:改变所有奇数号灯的状态. 三号开关:改变所有

解题报告 之 SOJ3353 Total Flow

解题报告 之 SOJ3353 Total Flow Description Time Limit: 2000 MS Memory Limit: 65536 K The Problem PROBLEM NAME: flow Farmer John always wants his cows to have enough water and thus has made a map of the N (1 <= N <= 700) water pipes on the farm that conne

POJ 2897 Monkeys&#39; Pride 解题报告

Description Background There are a lot of monkeys in a mountain. Every one wants to be the monkey king. They keep arguing with each other about that for many years. It is your task to help them solve this problem. Problem Monkeys live in different pl

解题报告 之 WHU1124 Football Coach

解题报告 之 WHU1124 Football Coach Description It is not an easy job to be a coach of a football team. The season is almost over, only a few matches are left to play. All of sudden the team manager comes to you and tells you bad news: the main sponsor of

ACM-ICPC 2017 Asia HongKong 解题报告

ACM-ICPC 2017 Asia HongKong 解题报告 任意门:https://nanti.jisuanke.com/?kw=ACM-ICPC%202017%20Asia%20HongKong 按AC次序: D - Card collection In an online game, a player can collect different types of power cards. Each power card can enable a player to have a uni