#AS2401. Rings(高级)
Rings(高级)
Description
ACSL Rings is a game where the object is to score points by tossing a ball through one of the 5 rings. Points are awarded as follows:
- Through the aqua or red ring - 1 point
- Through the orange or green ring - 3 points
- Through the black ring - 6 points
- Through the space where 2 rings overlap - the sum of the points for the 2 rings plus 1
- Any toss that is identified with a “+” at the end of the substring is awarded 2 extra points for having been tossed from a long distance
We will use a single letter to represent each of the above colors: aqua (A), red (R), orange (O), green (G), and black (B). The overlapping areas will be given by 2 letters: aqua and orange (AO or OA), orange and black (OB or BO), black and green (BG or GB), and green and red (GR or RG).
You will be given an integer, , indicating the number of players, followed by separate strings representing each player’s results for all tosses that go through at least one ring. Output a string for each player’s score in descending order using the format “player#-score”, each separated by a single space. Ties are broken based on the number of tosses; the fewer the tosses the better. We guarantee that all ties will be broken.
Input Format
The input will consist of an integer representing the number of players followed by a string for each player’s results as described above.
Output Format
Output a string in the format “player#-score” for each player’s score in descending order, each separated by a single space.
Explanation
Example:
Input
3
A R AO+
B+ GR OA B
G OB+
Explanation:
-
Player 1's tosses go through the aqua, red, and aqua & orange rings.
- A = 1
- R = 1
- AO+ = (1 + 3 + 1) + 2 = 7
- Score = 1 + 1 + 7 = 9.
-
Player 2 has a score of:
- B+ = 6 + 2 = 8
- GR = 3 + 1 + 1 = 5
- OA = 3 + 1 + 1 = 5
- B = 6
- Score = 8 + 5 + 5 + 6 = 24.
-
Player 3 has a score of:
- G = 3
- OB+ = (3 + 6 + 1) + 2 = 12
- Score = 3 + 12 = 15.
Player 2 is in first place with 24 points; Player 3 is in second place with 15 points; and Player 1 is in third place with 9 points. The output is the string 2-24 3-15 1-9.
Sample Input / Output
3
G R G R B G B G O B O B O B A O A O A O A O
B B B G G A A A O B A O B G B G A O A O
G B O A A A A B B B O O O G G G A O O B G R B G
3-78 1-69 2-66