## Mock CCC '24 Contest 1 J2 - Simple Elo Rating System

View as PDF

Points: 3
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type

Alice and Bob are playing chess, and they are using Elo rating system to calculate their rating after games. In each game Alice can only win (score ), lose (score ) or tie (score ). One of the good things about the Elo rating system is that one of the players gains precisely the same amount of points as the other one loses. Let Alice's rating be and Bob's rating be . We can work out Alice's expected score in a few steps:

1. Take the difference of ratings: .
2. Evaluate the ratio of the difference and : .
3. Find the value of ten to the exponent of this fraction: .
4. Add to this number: .
5. The expected score is the multiplicative inverse of the result from the previous step: .
6. Alice's new rating will be , where is known as the -factor, or development coefficient.

Alice and Bob are in a disagreement regarding their individual rankings after participating in a series of games. Due to their challenges in mathematics, they have asked you to be the judge and calculate their respective final ratings.

#### Input Specification

The first line of input contain four space-separated integers, , , , and .

The second line of input contain characters, if the character of the string is W means Alice won the game, T means Alice is tied with Bob for the game and L means Alice lost the game.

#### Output Specification

Output lines, the line should contain two space-separated integers, Alice's rating after the game and Bob's rating after the game.

Answer within will be accepted.

#### Sample Input

9 1000 1000 40
TTTLLLWWW

#### Sample Output

1000.0 1000.0
1000.0 1000.0
1000.0 1000.0
980.0 1020.0
962.3 1037.7
946.6 1053.4
972.5 1027.5
995.7 1004.3
1016.2 983.8

#### Explanation for Sample

In the beginning, the expected score between Alice and Bob is the same. In other words, Alice is expected to win as often as Bob is. Therefore, as Alice and Bob tie, there is no rating change after the first three games. However, after game , Alice has lost. Her expected score is still , but her score is . As a result, she will lose rating points. Bob on the other hand will win rating points. After Alice loses another two games, her rating will end up at points. When she wins, her expected score is . By winning, her score for that game is , and her rating will increase by points. Hence, after the game, Alice's rating become .