http://www.codechef.com/COOK56/problems/STRAB/
Can someone explain the dp approach except the one given in the editorial ? Also if someone know similar problems , please provide the link :) .
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
http://www.codechef.com/COOK56/problems/STRAB/
Can someone explain the dp approach except the one given in the editorial ? Also if someone know similar problems , please provide the link :) .
Название |
---|
In fact, you don't need dp in this problem.
Let's count the following thing (just using a loop over bitmasks): how many there are strings of length L than consist only of A and B and are good (not hated, i. e., don't contain any hated subword).
Now let's iterate over all possible positions of non-AB characters (again as a loop over bitmasks). Obviously, if there is any hated word, it will be between two two consecutive non-AB characters. So we can use the thing we calculated earlier to fill all characters between non-AB ones.
thanks ,it will be very helpful if you can you refer someone's implemented code ? sorry to bother , i got it :).
Nice solution, and it seems to be O(n2n) too (don't know why you got downvoted). Why is it not in the editorial?