I'm trying to do this problem: http://acm.timus.ru/problem.aspx?space=1&num=1455. It gives a dictionary consisting of 'n' words (1 <= n <= 100). Each word consists of from 1 to 100 small latin letters. It's demanded to find an expression which can be formed by at least two different sequences of words from the dictionary. The expression should not be more than 20000 characters long. If the problem has several solutions, you may output any of them. I've heard that it's possible to solve with a dp on the trie that contains the words from the dictionary, but I still didn't realize how to do that after a lot of time thinking. Any help would be appreciated. Thanks in advance.