Hello Codeforces,
I read this interesting problem a while ago and don't know how to solve it efficiently. Any hints?
I tried mapping strings to states but that obviously sucks. Any help would be appreciated.
Thank you!
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 153 |
10 | luogu_official | 152 |
Hello Codeforces,
I read this interesting problem a while ago and don't know how to solve it efficiently. Any hints?
I tried mapping strings to states but that obviously sucks. Any help would be appreciated.
Thank you!
Name |
---|
This can be solved with dp in O(n3)
Say dp[i][j] is the number of possible ways to remove exactly substring [i, j]. Obviously, dp[i][i + 1] = (s[i] = = s[i + 1]).
Now to calculate dp[i][j] let's check with which position was s[i] deleted. If we deleted s[i] with s[k], it has to be s[k] = s[i] and then we had to delete [i + 1, k - 1] separately (and, therefore, to delete [k + 1, j] separately. So we get dp[i + 1][k - 1] ways to delete [i, k] in this manner and dp[k + 1][j] to delete [k + 1, j]. Note that deletions in those substrings are independent and don't afffect each other. So to get total number of possible ways, we have to multiply this by . In total, we get the following dp:
Hope that helps
Thank you so much for the detailed comment. The idea you described helps a lot.
Please tell me, how to create an account on that site?
Here you go
Thanks a lot!