CF1800F.Dasha and Nightmares

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Dasha, an excellent student, is studying at the best mathematical lyceum in the country. Recently, a mysterious stranger brought nn words consisting of small latin letters s1,s2,,sns_1, s_2, \ldots, s_n to the lyceum. Since that day, Dasha has been tormented by nightmares.

Consider some pair of integers i,j\langle i, j \rangle ( 1ijn1 \le i \le j \le n ). A nightmare is a string for which it is true:

  • It is obtained by concatenation sisjs_{i}s_{j} ;
  • Its length is odd;
  • The number of different letters in it is exactly 2525 ;
  • The number of occurrences of each letter that is in the word is odd.

For example, if si=s_i= "abcdefg" and sj=s_j= "ijklmnopqrstuvwxyz", the pair i,j\langle i, j \rangle creates a nightmare.

Dasha will stop having nightmares if she counts their number. There are too many nightmares, so Dasha needs your help. Count the number of different nightmares.

Nightmares are called different if the corresponding pairs i,j\langle i, j \rangle are different. The pairs i1,j1\langle i_1, j_1 \rangle and i2,j2\langle i_2, j_2 \rangle are called different if i1i2i_1 \neq i_2 or j1j2j_1 \neq j_2 .

输入格式

The first line contains a single integer nn ( 1n21051 \le n \le 2 \cdot 10^5 ) — the number of words.

The following nn lines contain the words s1,s2,,sns_1, s_2, \ldots, s_n , consisting of small latin letters.

It is guaranteed that the total length of words does not exceed 51065 \cdot 10^6 .

输出格式

Print a single integer — the number of different nightmares.

输入输出样例

  • 输入#1

    10
    ftl
    abcdefghijklmnopqrstuvwxy
    abcdeffghijkllmnopqrsttuvwxy
    ffftl
    aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy
    thedevid
    bcdefghhiiiijklmnopqrsuwxyz
    gorillasilverback
    abcdefg
    ijklmnopqrstuvwxyz

    输出#1

    5

说明/提示

In the first test, nightmares are created by pairs 1,3\langle 1, 3 \rangle , 2,5\langle 2, 5 \rangle , 3,4\langle 3, 4 \rangle , 6,7\langle 6, 7 \rangle , 9,10\langle 9, 10 \rangle .

首页