##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a string consisting only of the characters L and R.
Consider any non-empty substring of . You must delete all of its characters using the following operation:
L; if it is R, it costs .R; if it is L, it costs .Each substring is processed independently, starting from its original contents.
For every non-empty substring of , consider the minimum total cost needed to delete it completely. Find the sum of these minimum costs over all non-empty substrings of .
L and RThe only substring is , and it can be deleted from the left for free.
The one-character substrings cost . For , deleting the leftmost character costs , after which the remaining character can be deleted for free. Thus the total is .
The substrings , , , and cost . The minimum costs for and are and , respectively, so their sum is .
The only substrings with positive minimum cost are , , and . Each of them costs , giving a total of .
The one-character substrings and the substrings consisting only of equal characters cost . The positive minimum costs of the remaining substrings add up to .
Processing every substring independently and adding its minimum deletion cost gives .