CF798B Mike and strings
题目描述
Mike 有 $n$ 个字符串 $s_1,s_2,\dots,s_n$,每个字符串均由小写字母构成。 每次移动你可以选择一个字符串 $s_i$,第 $1$ 个字符移动最后,比如字符串 `coolmikecoolmike`,移动 $1$ 次变成字符串 `oolmikecoolmikec`。
请计算至少需要移动多少次,可以使得 $n$ 个字符串都变成相同。
输入格式
第一行,一个整数 $n$($1\leq n\leq50$)。 接下来 $n$ 行,每行一个字符串,每个字符串的长度相当,且长度不超过 $50$。
输出格式
输出最小移动次数,无解则输出 $-1$。
说明/提示
In the first sample testcase the optimal scenario is to perform operations in such a way as to transform all strings into "zwoxz".