anm_coder007's blog

By anm_coder007, history, 11 days ago, In English,

https://www.spoj.com/problems/DNALAB/

I am trying to solve this problem using dp bitmasks. Here's my approach :

Firstly , I precompute the cost it takes to merge 2 strings.

Cost[i][j] — cost to merge string 'i' and string 'j'. Formally, It is essentially the smallest string which contains string 'i' and string 'j'.

Then I define a state dp[i] — the minimum length considering only the strings which have set bits in i.

But I am stuck at a point where if i get same minimum length from 2 states i need to pick the lexicographically smallest one.

Can somebody help with this case I am stuck on ??