Hi! I’m having trouble with this problem right here:
Fullmetal Alchemist II
There is no solution in the guide at the moment and I also was not able to find it in codeforces.
Initially my thoughts are to try all permutations of the words, if we are putting the word i and then the word j, if i have a suffix in common with j, I can omit it, but there is also the cases where a word itself can be found when I join two of them, for example in this case:
apo
ole
poo
Folowing the greedy of omitting a common suffix/preffix i would do apole when joining “apo” and “ole”, but the optimal is apoole because now poo is visible as well. I think this is doable but it is really awful to code, cause I can preprocess if word z is found when combining word x and y but then I also need to consider if its better to omit the common suffix/preffix, idk, it is just messy in my head.
Can I have some hints or maybe the full solution? Thank you in advance!