LCC '22 Contest 5 J3 - Guess the Elo

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Annie just learned how to play competitive chess and is learning about the ELO-MMR system. She doesn't really know how it works, but she does know that the higher ELO a player is, the more skilled the player.

Annie has N potential opponents (with funky usernames) that she wants to know the ELO of. She will use their usernames to guess their ELOs. Each username will only have upper or lowercase latin characters (letters from A-Z or a-z) and arabic numerals (digits from 0-9).

She will guess a player's ELO with the following steps:

  1. The player's ELO is initially 30 minus the number of characters in the username, multiplied by 50.

  2. If the username has no numerical digits, the player's ELO is multiplied by 2.

  3. Every numerical digit between two letters will increase the ELO of the player by the value of that digit multiplied by 10.

    • For example, the username b2w3n will have its initial ELO increased by 2 \times 10 = 20 and again by 3 \times 10 = 30.
  4. Every trailing numerical digit (after the last letter or all digits if there are no letters) will decrease the ELO of the player by the value of that digit multiplied by 10.

    • For example, the username a12 will have its initial ELO decreased by 1 \times 10 = 10 and again by 2 \times 10 = 20.
  5. Every two identical consecutive characters will decrease the ELO of the player by 5.

    • For example, having zz in the username will decrease the ELO of the player by 5, and having AAA in the username will decrease the ELO of the player by 10.

Given T opponents, can you help Annie guess all their ELOs? Note that ELOs may be negative, that's fine!

Constraints

1 \le T \le 10^5

3 \le |S| \le 30, where |S| denotes the number of characters in an opponent's username.

Input Specification

The first line will contain T.

The next T lines will contain a valid username according to the above specifications.

Output Specification

For each username, output the guessed ELO on a new line.

Sample Input

4
mar5flaa
Pingu
NOTanieni6002
aazzaazzron

Sample Output

1145
2500
765
1880

Explanation for Sample Output

The first username, mar5flaa, has 8 characters for an initial ELO of (30-8) \times 50 = 1100. Because there is a 5 in between characters r and f, the ELO is increased by 5 \times 10 = 50. Finally, because there are two identical consecutive characters (aa), the ELO is decreased by 5 for a total of 1100+50-5 = 1145.

The second username, Pingu, has 5 characters for an initial ELO of (30-5) \times 50 = 1250. Since there are no numerical digits in the username, however, the ELO is multiplied by 2 to equal 2500.

The third username, NOTanieni6002, has 13 characters for an initial ELO of (30-13) \times 50 = 850. Because there is a trailing 6002, the ELO is decreased by 6 \times 10 = 60, 2 \times 0 = 0 (twice), and 2 \times 10 = 20. The consecutive 0s also decrease the ELO by 5, for a total of 850-60-20-5 = 765.


Comments

There are no comments at the moment.