ACM-ICPC Scoreboard
InterviewTime limit1sMemory limit128 MB
Replay the judging log to count each team's solved problems and penalty time, then print all teams in rank order.
- Level
Easy3 of 10
- Topics
- Simulation, Sorting
- Solved
- No attempts yet
Problem
ACM-ICPC is a programming contest for university students. Three people form one team, and each team gets a single computer. Regional contests pick the representatives, and the selected teams compete in the World Finals. A contest has around 10 problems, and a team has 5 hours to get as many of them accepted as possible. A rejected submission comes back as one of run-time error, time-limit exceeded, or wrong answer.
Ranks are decided as follows.
- A team that solved more problems ranks higher.
- If two teams solved the same number of problems, the team with the smaller total time ranks higher.
- The total time is the sum of the time values of the problems the team solved. When a team solves a problem, its time value is the number of minutes from the start of the contest until the accepted submission, plus a penalty of 20 times the number of rejected submissions the team made on that problem before it was accepted.
- Rejected submissions on a problem that was never accepted add nothing to the total time.
- Submissions on a problem that the team already solved are ignored, whether they are accepted or rejected. Only the first accepted submission counts.
- Two teams with the same number of solved problems and the same total time share a rank.
You are given the judging log of the teams. Print the result of the contest.
Input
The first line contains the number of teams (), the number of problems (), and the number of judging log entries ().
Each of the next lines contains one judging log entry: the elapsed time (a non-negative integer at most 300), the team number (an integer between and ), the problem number (an integer between and ), and the verdict. The verdict is one of AC, RE, TLE, WA, meaning Accepted, Run-time Error, Time-limit Exceeded, and Wrong Answer. Only AC counts as solving the problem, and the other three count as rejected. The entries are given in judging order, so the elapsed times never decrease.
Output
Print all teams in rank order, one per line. Teams that share a rank are printed with the smaller team number first. On each line print the team number, the number of solved problems, and the total time, separated by single spaces.
Note
In the first example, team 1 got problem 1 accepted at minute 30 after two rejected submissions, so the time value of that problem is . Team 1 got problem 2 accepted at minute 100, so its total time is . Team 2 got problem 1 accepted at minute 20, and its later submission on problem 1 is ignored because the problem was already solved. Team 2 never solved problem 2, so that rejected submission adds nothing to the total time.