#P17745. 「RSOI-1B」比赛 / contest
「RSOI-1B」比赛 / contest
Background
Problem source: 【HT-121-Div.3】Walnut CSP-J Mock Contest
Problem Description
Little R has become the organizer of PSC 2027, and he needs to check the results of contestants. The contest has problems in total, and each problem has a full score of .
He has obtained submission records, each containing the contestant's name, the problem number, and the score on that problem. The contestant's name is a string, and the rest are integers.
Now, he wants to know the ranking of the contestants if the contest uses the OI format or the IOI format.
- OI format: a contestant's score on each problem is determined by his last submission on that problem.
- IOI format: a contestant's score on each problem is determined by his submission with the highest score on that problem.
A problem that a contestant has not submitted to scores . It is guaranteed that every contestant has at least one submission.
When outputting the ranking, contestants are sorted by their total scores first.
If the total scores are equal, the ranks are the same, but when outputting, sort the contestants by their names in lexicographical order. The one with the smaller lexicographical order is output first.
When ranking, equal scores share the same rank, and the following ranks skip the number of people occupying that rank.
For example, if the total scores from high to low are , then the ranks are , not .
Please refer to the samples for details.
Input Format
The input contains lines in total.
The first line contains three positive integers , representing the number of contestants, the total number of submissions, and the number of problems.
The next lines each contain a string and two integers, representing the contestant's name, the problem number, and the score on that problem.
The next line contains a string:
- If the string is
OI, Little R wants to know the ranking of the contestants if the contest uses the OI format. - If the string is
IOI, Little R wants to know the ranking of the contestants if the contest uses the IOI format.
Output Format
Output lines in total, representing the ranking of the contestants.
On the -th line, first output the contestant's rank, then the contestant's name, and finally the contestant's total score.
3 11 3
cyx 1 100
xlq 3 90
cht 3 95
cyx 2 90
cyx 2 95
cht 3 0
cyx 3 60
xlq 1 80
cht 2 100
cht 1 100
cyx 3 90
OI
1 cyx 285
2 cht 200
3 xlq 170
5 13 3
lw 1 100
lw 2 90
crx 1 100
crx 2 80
crx 2 100
lw 3 100
hy 3 100
hy 1 10
lw 2 100
crx 3 100
lyt 1 50
zyq 2 20
zyq 3 30
IOI
1 crx 300
1 lw 300
3 hy 110
4 lyt 50
4 zyq 50
Hint
Sample Explanation #1
- 's score: , so he ranks first.
- 's score: , so he ranks second. Note that since this is the OI format, 's last submission on problem 3 scored , and this submission is counted into the total score.
- 's score: , so he ranks third.
Sample Explanation #2
- 's score: , so he ranks first.
- 's score: , so he also ranks first. Note that since this is the IOI format, 's submission with the highest score on problem 2 ( points) is counted into his total score. Also, since 's name is lexicographically greater than 's, is output first.
- 's score: , so he ranks third.
- 's score: , so he ranks fourth.
- 's score: , so he also ranks fourth.
Constraints
For all testdata, it is guaranteed that:
- .
- Contestants' names consist of lowercase letters and have length .
- Problem numbers are between , and scores on each problem are between .
::cute-table{tuack}
| Subtask | Special property | Score | |
|---|---|---|---|
| 1 | It is guaranteed that no two total scores are equal | 40 | |
| 2 | None | 20 | |
| 3 | 40 |
Translated by QwenWork