Hi everyone!
I am trying to learn DP, and I stumbled across this question on TopCoder. While I have a hunch that it will involve bitmasks, the naive approach, i.e. generating all the sequences, simulating the matches and finding the solution would involve O(n.n!) time. And that's too much for 2 ≤ n ≤ 16.
I have some other unformed ideas, but I wanted to know how do I tackle such problems in general? Thanks!




