Superstring - MarisaOJ: Marisa Online Judge

Superstring

Time limit: 1000 ms
Memory limit: 256 MB
You are given $n$ string $S_1, S_2,...,S_n$. Find the shortest string $S$ that $S_1, S_2,...,S_n$ are substrings of $S$. ### Input - The first line contains an integer $n$. - The next $n$ lines, each line contains a string $S_i$. ### Output - Print the shortest string. ### Constraints - $1 \le n \le 20$. - $1 \le |S_i| \le 100$. ### Example Input: ``` 3 ab bcc da ``` Output: ``` dabcc ```