Hoj2564 regional ranking

Source: Internet
Author: User

Background

 

In the ACM/ICPC Regional Contest, all the teams are ranked according to the most problems solved. for the purposes of awards, or in determining qualifier (s) for the world finals, teams who solve the same number of problems are ranked by least total time. the total time is the sum of the time consumed for each problem solved. the time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the first accepted run plus 20 penalty minutes for every rejected run for that problem regardless of submittal time. there is no time consumed for a problem that is not solved. if there is still a tie, rank them in Lexicographic Order. there are always 9 problmes marked by A to I for a regional contest. the contest starts at and ends. now, given the submissions of all teams in time order, please print the final ranklist.

 

Input

 

Multiple test cases, each starts with two positive integer, n (10 <= n <= 100) and M (20 <= m <= 10000 ), where N is the number of the teams and m is the number of the submissions during the contest. the names (composed by only dights and letters, length is no more than 20) of the n teams come in the following n lines. and then, there are m lines, each line tells a submission, in the form of "problem time (XX: XX) jundgement (maybe one of AC, WA, TLE, MLE, Ce, RE and PE, Only AC means the right answer) teamname ".

 

Output

 

For each case, print the final ranklist in n lines, each line contains only a team name. Print a blank line after each case.

 

Sample Input



10 26liuleiCaiSOFTo0oicecreamdavidlovesWorldWar3iaag88yukui0716xunxunrainbowrainE 09:28:40 WA liuleiA 09:39:18 TLE CaiSOFTE 09:39:48 WA liuleiA 09:41:48 AC CaiSOFTE 09:42:57 WA o0oB 09:47:14 WA icecreamB 10:06:11 RE CaiSOFTD 10:09:15 WA icecreamB 10:09:25 AC CaiSOFTE 10:12:05 AC liuleiC 10:15:34 AC davidlovesB 10:32:27 WA WorldWar3C 10:37:35 WA CaiSOFTC 10:38:38 AC CaiSOFTC 10:50:06 AC iaag88B 10:50:33 AC liuleiB 10:57:48 WA WorldWar3B 11:03:33 AC iaag88D 11:07:49 AC CaiSOFTD 11:07:53 WA yukui0716B 11:16:37 WA WorldWar3E 11:18:30 AC CaiSOFTE 11:35:54 TLE iaag88E 11:40:25 WA davidlovesE 11:52:34 WA iaag88B 11:59:34 AC icecream
Sample output
CaiSOFTliuleiiaag88davidlovesicecreamo0orainbowrainWorldWar3xunxunyukui0716

Question:

Given the competition evaluation rules of ACM/ICPC regional, multiple groups of input, Enter K submissions of n teams during the competition to determine the ranking of each team.

 

Analysis:

You can enter this question consecutively. However, the sorting rules of this question need to be carefully considered:

  • Calculate the time difference from 9:00:00 to the first AC: the AC Time of the current question
  • Before the AC, the penalty is 20 minutes for each submission of errors
  • If one question does not have an AC, no penalty is calculated.
  • The sorting rule is to first sort by the number of questions, with the minimum time at the same time. If it is still the same, it will be sorted in alphabetical order.
  • The sorting by letter is case insensitive.

Note that the tedious data of this question may be handed over after an AC attack. If yes, be sure not to update the time. If it is wrong, no penalty will be calculated!

 

Implementation:

Use one map to save the situation of each team, and use another string array to save the team name for sorting. Use the structure Prob to save the time consumed, the number of penalty times, and whether or not to AC each team question, use the team struct to store the details of a team's nine questions. The member functions getscroe () and gettime () calculate the number of questions and the penalty respectively. When inputting a question, you only need to judge whether the question is AC and then classify it. Finally, the string array can be directly sort and output according to the specified rule. It is well calculated. You can convert the number of 60 bytes into decimal addition and subtraction, and the number of penalty times increases by one each time.

I will always forget the small details of the output space at the end of each group of data.

Here, I would like to make a small sigh for hoj. Many functions in cctype and cstring on hoj cannot be used. To ignore case-sensitive strings, you need to write conversion and comparison functions yourself.

If you want to use hash to store a team, you can write the team name directly in the team. However, considering that small-scale data may conflict with small-prime numbers, the team will occupy a large amount of space, finally, I chose the map container with STL. If I have time, I can use the dictionary tree to try to rewrite the program. I hope I will have a new experience.

 

Code:

 

# Include <iostream> <br/> # include <cstring> <br/> # include <cctype> <br/> # include <map> </P> <p> using namespace STD; </P> <p> struct prob <br/>{< br/> int rejects; <br/> int time; <br/> bool AC; </P> <p> prob () <br/> {<br/> rejects = 0; <br/> time = 0; <br/> AC = false; <br/>}< br/>}; </P> <p> struct team <br/>{< br/> prob doing [9]; </P> <p> int gettime () <br/> {<br/> int time = 0; <br/> for (INT I = 0; I <9; I ++) <br/>{< br/> If (doing [I]. AC) <br/> time + = doing [I]. time + doing [I]. rejects * 20*60; <br/>}< br/> return time; <br/>}</P> <p> int getscore () <br/> {<br/> int score = 0; <br/> for (INT I = 0; I <9; I ++) <br/> If (doing [I]. AC) <br/> score ++; <br/> return score; <br/>}< br/>}; </P> <p> typedef Map <string, team> Team; <br/> Team team; </P> <p> string strlow (string a) <br/>{< br/> int Len =. Length (); <br/> for (INT I = 0; I <Len; I ++) <br/> If (isalpha (A [I]) <br/> A [I] | = 0x20; <br/> return a; <br/>}</P> <p> bool stricmp (string, string B) <br/>{< br/> string x = strlow (A), Y = strlow (B); <br/> return x <Y; <br/>}</P> <p> bool CMP (string a, string B) <br/>{< br/> If (TEAM [A]. getscore ()! = Team [B]. getscore () <br/> return team [A]. getscore ()> Team [B]. getscore (); <br/> If (TEAM [A]. gettime ()! = Team [B]. gettime () <br/> return team [A]. gettime () <team [B]. gettime (); <br/> return stricmp (a, B); <br/>}</P> <p> int main () <br/>{< br/> const int time0 = 32400; <br/> int n, m, Len; <br/> string TM [200]; <br/> while (scanf ("% d", & N, & M )! = EOF) <br/>{< br/> Team. clear (); <br/> Len = 0; <br/> string name, Res; <br/> char P; <br/> int HH, mm, SS, time; <br/> for (INT I = 0; I <n; I ++) <br/>{< br/> CIN> name; <br/> Team TMP; <br/> Team [name] = TMP; <br/> TM [Len ++] = Name; <br/>}</P> <p> for (INT I = 0; I <m; I ++) <br/>{< br/> scanf ("% * C % d: % d", & P, & HH, & mm, & SS ); <br/> CIN> res> name; <br/> time = HH * 3600 + mm * 60 + SS; <br/> If (! Team [name]. doing [p-'a']. AC) <br/>{< br/> If (RES = "AC") <br/>{< br/> Team [name]. doing [p-'a']. AC = true; <br/> Team [name]. doing [p-'a']. time = Time-time0; <br/>}< br/> else <br/>{< br/> Team [name]. doing [p-'a']. rejects ++; <br/>}< br/> sort (TM, TM + N, CMP ); <br/> for (INT I = 0; I <n; I ++) <br/> cout <TM [I] <Endl; <br/> cout <Endl; <br/>}< br/>} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.