Naming Convention

akash.kuet Criterion 2020 Round 4
Limits 1s, 512 MB

Tony works in a multinational technology company named Voogle LLC. The employees of Voogle follow certain rules to name a function. They have a list of unique function names and each name contains lowercase letters. But they will choose names which consisted entirely of at least two names from the list. Suppose if the list contains function names such as "sum", "add", "addsum", they will choose "addsum" name because it is made of concatenation of "add" and "sum".

So you are given a list of words. You have to find out words which are made of concatenation of at least two words from the list. Print the words so that their relative order is maintained from the input list. If no words are found, then print “No solution”.


Input starts with an integer N, the number of names the list contains. In the next line there are N words, each character of the word contain lowercase letters.


1≤Each string length≤100


Output list of words which follows Voogle’s function naming convention or “No solution”.


a ab ac aa acab
aa acab

aa contains a twice and acab contains ac and ab.


Login to submit.


44% Solution Ratio
code_hard123Earliest, Mar '20
NaimulFastest, 0.0s
mahdi.hasnatLightest, 131 kB
probableShortest, 601B
Toph uses cookies. By continuing you agree to our Cookie Policy.