| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3447 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | turmax | 3317 |
| 9 | tourist | 3307 |
| 10 | jiangbowen | 3291 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 142 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 7 | AmShZ | 135 |
| 8 | BledDest | 132 |
| 8 | maroonrk | 132 |
| 10 | qwexd | 129 |
| Название |
|---|



You can check-out my submission. I used dynamic programming.
https://codeforces.me/contest/1506/submission/111002216
what was your intuition behind this approach? basically what is the overlapping subproblem in this solution?
The idea was to find the answer if the string was to end at ith index such that s[i] = '*'.
dp[i] represents the minimum number of replacements for the prefix s[0]....s[i] where s[i]='*'.
dp[index of first occurrence of '*' in s] = 1 (base condition).
The transition is pretty simple, if s[i]='*', and because it is the last character of our prefix, we will have to change it to 'x'.
So we traverse over all the previous indices 'j' of s such that s[j]='*' and (i — j)<=k (due to the range given) and do the transition dp[i]=min(dp[i],dp[j]+1) (+ 1 because we are replacing the current character to 'x' as well).
Our final answer will be dp[index of last '*' character in s].
Here's a recursive DP approach , I think it is pretty intuitive.
https://codeforces.me/contest/1506/submission/111108103
My submission with explanatory comments