{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e假设给定两个字符串$$$a$$$和$$$b$$$。您可以任意次地应用以下操作:选择$$$a$$$或$$$b$$$的连续子串,并按非降序对其中的字符进行排序。让$$$f(a, b)$$$是您必须应用的使它们相等的最小操作次数(如果使用这些操作无法使$$$a$$$和$$$b$$$相等,则为$$$f(a, b) \u003d 1337$$$)。\u003c/p\u003e\u003cp\u003e例如:\u003c/p\u003e\u003cul\u003e\u003cli\u003e$$$f(\\text{ab}, \\text{ab}) \u003d 0$$$;\u003c/li\u003e\u003cli\u003e$$$f(\\text{ba}, \\text{ab}) \u003d 1$$$(在一次操作中,我们可以对整个第一个字符串进行排序);\u003c/li\u003e\u003cli\u003e$$$f(\\text{ebcda}, \\text{ecdba}) \u003d 1$$$(在一次操作中,我们可以对第二个字符串中从第$$$2$$$个字符到第$$$4$$$个字符结束的子串进行排序);\u003c/li\u003e\u003cli\u003e$$$f(\\text{a}, \\text{b}) \u003d 1337$$$。\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e给定长度相等的$$$n$$$个字符串$$$s_1, s_2, \\dots, s_k$$$。计算$$$\\sum \\limits_{i \u003d 1}^{n} \\sum\\limits_{j \u003d i + 1}^{n} f(s_i, s_j)$$$。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数$$$n$$$($$$1 \\le n \\le 2 \\cdot 10^5$$$)— 字符串的数量。\u003c/p\u003e\u003cp\u003e然后是$$$n$$$行,每行包含一个由小写拉丁字母组成的字符串$$$s_i$$$。这些字符串$$$|s_1| \u003d |s_2| \u003d \\ldots \u003d |s_n|$$$和$$$n \\cdot |s_1| \\le 2 \\cdot 10^5$$$两两不同。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e输出一个整数:$$$\\sum \\limits_{i \u003d 1}^{n} \\sum\\limits_{j \u003d i + 1}^{n} f(s_i, s_j)$$$。\u003c/p\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\nzzz\nbac\nabc\nacb\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4015\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\na\nb\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1337\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}