33OJ
登录 注册

#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 nn contestants. The contest has kk problems in total, and each problem has a full score of 100100.

He has obtained mm 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 00. 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 100,70,70,20100,70,70,20, then the ranks are 1,2,2,41,2,2,4, not 1,2,2,31, 2, 2,3.

Please refer to the samples for details.

Input Format

The input contains m+2m+2 lines in total.

The first line contains three positive integers n,m,kn,m,k, representing the number of contestants, the total number of submissions, and the number of problems.

The next mm 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 nn lines in total, representing the ranking of the contestants.

On the ii-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

  • cyx\text{cyx}'s score: 100+95+90=285100+95+90=285, so he ranks first.
  • cht\text{cht}'s score: 100+100+0=200100+100+0=200, so he ranks second. Note that since this is the OI format, cht\text{cht}'s last submission on problem 3 scored 00, and this submission is counted into the total score.
  • xlq\text{xlq}'s score: 80+0+90=17080+0+90=170, so he ranks third.

Sample Explanation #2

  • crx\text{crx}'s score: 100+100+100=300100+100+100=300, so he ranks first.
  • lw\text{lw}'s score: 100+100+100=300100+100+100=300, so he also ranks first. Note that since this is the IOI format, lw\text{lw}'s submission with the highest score on problem 2 (100100 points) is counted into his total score. Also, since lw\text{lw}'s name is lexicographically greater than crx\text{crx}'s, crx\text{crx} is output first.
  • hy\text{hy}'s score: 10+0+100=11010+0+100=110, so he ranks third.
  • lyt\text{lyt}'s score: 50+0+0=5050+0+0=50, so he ranks fourth.
  • zyq\text{zyq}'s score: 0+20+30=500+20+30=50, so he also ranks fourth.

Constraints

For all testdata, it is guaranteed that:

  • 1≤n,m,k≤1051 \le n,m,k \le 10^5.
  • Contestants' names consist of lowercase letters and have length ≤10\le 10.
  • Problem numbers are between 1∼k1 \sim k, and scores on each problem are between 0∼1000 \sim 100.

::cute-table{tuack}

Subtask n,m,k≤n,m,k \le Special property Score
1 10410^4 It is guaranteed that no two total scores are equal 40
2 10310^3 None 20
3 10510^5 40

Translated by QwenWork