CF1800F.Dasha and Nightmares

普及+/提高

通过率:0%

时间限制:4.00s

内存限制:512MB

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 (1≤i≤j≤n1 \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 i1≠i2i_1 \neq i_2 or j1≠j2j_1 \neq j_2.

达莎是一名优秀的学生,就读于全国最好的数学中学。最近,一位神秘的陌生人给这所中学带来了 nn 个仅由小写拉丁字母组成的单词:s1,s2,…,sns_1, s_2, \ldots, s_n。自那天起,达莎便一直被噩梦困扰。

考虑某一对整数 ⟨i,j⟩\langle i, j \rangle(满足 1≤i≤j≤n1 \le i \le j \le n)。若一个字符串满足以下全部条件,则称其为一个“噩梦”:

  • 它由 sis_i 与 sjs_j 拼接而成,即形如 sisjs_{i}s_{j};
  • 其长度为奇数;
  • 其中恰好包含 2525 个不同的字母;
  • 每一个在该字符串中出现的字母,其出现次数均为奇数。

例如,若 si=s_i = "abcdefg" 且 sj=s_j = "ijklmnopqrstuvwxyz",则该对 ⟨i,j⟩\langle i, j \rangle 就会产生一个噩梦。

只要达莎统计出噩梦的总数,她就能摆脱噩梦。但噩梦数量太多,因此达莎需要你的帮助。请计算不同噩梦的总数。

若两个噩梦对应的数对 ⟨i,j⟩\langle i, j \rangle 不同,则称这两个噩梦不同。数对 ⟨i1,j1⟩\langle i_1, j_1 \rangle 与 ⟨i2,j2⟩\langle i_2, j_2 \rangle 被称为不同,当且仅当 i1≠i2i_1 \neq i_2 或 j1≠j2j_1 \neq j_2。

输入格式

The first line contains a single integer nn (1≤n≤2⋅1051 \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 5⋅1065 \cdot 10^6.

第一行包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)—— 单词的数量。

接下来的 nn 行包含单词 s1,s2,…,sns_1, s_2, \ldots, s_n,每个单词均由小写拉丁字母组成。

保证所有单词的总长度不超过 5⋅1065 \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.

在第一次测试中,噩梦由以下数对产生:⟨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。

输入解题思路,AI测评打分。不知道怎么写?

首页