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

View as PDF

Submit solution


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 N games. In each game Alice can only win (score =1), lose (score =0) or tie (score =0.5). 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 R_A and Bob's rating be R_B. We can work out Alice's expected score in a few steps:

  1. Take the difference of ratings: R_B - R_A.
  2. Evaluate the ratio of the difference and 400: \frac{R_B - R_A}{400}.
  3. Find the value of ten to the exponent of this fraction: 10^\frac{R_B - R_A}{400}.
  4. Add 1 to this number: 10^\frac{R_B - R_A}{400} + 1.
  5. The expected score is the multiplicative inverse of the result from the previous step: \frac{1}{10^\frac{R_B - R_A}{400} + 1}.
  6. Alice's new rating will be R_{newA} = R_A \ + (\text{score} - \text{expected score}) \times K, where K is known as the k-factor, or development coefficient.

Alice and Bob are in a disagreement regarding their individual rankings after participating in a series of N 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, N \ (1 \leq N \leq 100), R_A \ (1 \leq R_A \leq 5000), R_B \ (1 \leq R_B \leq 5000), and K \ (10 \leq K \leq 40).

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

Output Specification

Output N lines, the i^{th} line should contain two space-separated integers, Alice's rating after the i^{th} game and Bob's rating after the i^{th} game.

Answer within \pm 0.1 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 4, Alice has lost. Her expected score is still \frac{1}{2}, but her score is 0. As a result, she will lose (0-\frac{1}{2}) \times 40=20 rating points. Bob on the other hand will win 20 rating points. After Alice loses another two games, her rating will end up at 946.6 points. When she wins, her expected score is 0.351. By winning, her score for that game is 1, and her rating will increase by (1-0.351) \times 40=25.9 points. Hence, after the 7^{th} game, Alice's rating become 972.5.


Comments


  • 0
    BigTeddyCN  commented on Aug. 5, 2024, 6:59 p.m.

    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.