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 RA and Bob's rating be RB. We can work out Alice's expected score in a few steps:

  1. Take the difference of ratings: RBRA.
  2. Evaluate the ratio of the difference and 400: RBRA400.
  3. Find the value of ten to the exponent of this fraction: 10RBRA400.
  4. Add 1 to this number: 10RBRA400+1.
  5. The expected score is the multiplicative inverse of the result from the previous step: 110RBRA400+1.
  6. Alice's new rating will be RnewA=RA +(scoreexpected score)×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 (1N100), RA (1RA5000), RB (1RB5000), and K (10K40).

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

Output Specification

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

Answer within ±0.1 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 4, Alice has lost. Her expected score is still 12, but her score is 0. As a result, she will lose (012)×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 (10.351)×40=25.9 points. Hence, after the 7th 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.