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:
- Take the difference of ratings:
.
- Evaluate the ratio of the difference and
:
.
- Find the value of ten to the exponent of this fraction:
.
- Add
to this number:
.
- The expected score is the multiplicative inverse of the result from the previous step:
.
- 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
Copy
9 1000 1000 40
TTTLLLWWW
Sample Output
Copy
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
.
Comments
How can we find out the test case sets? The sample test passed, but got WA for the first test case. Output is below.
2393.0 4972.0 2425.0 4940.0 2457.0 4908.0 2489.0 4876.0 2505.0 4
I can guess the K = 32 for the test input, but I have no idea where stuck. please help.