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 n words consisting of small latin letters s1,s2,…,sn to the lyceum. Since that day, Dasha has been tormented by nightmares.
Consider some pair of integers ⟨i,j⟩ (1≤i≤j≤n). A nightmare is a string for which it is true:
- It is obtained by concatenation sisj;
- Its length is odd;
- The number of different letters in it is exactly 25;
- The number of occurrences of each letter that is in the word is odd.
For example, if si= "abcdefg" and sj= "ijklmnopqrstuvwxyz", the pair ⟨i,j⟩ 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⟩ are different. The pairs ⟨i1,j1⟩ and ⟨i2,j2⟩ are called different if i1=i2 or j1=j2.
达莎是一名优秀的学生,就读于全国最好的数学中学。最近,一位神秘的陌生人给这所中学带来了 n 个仅由小写拉丁字母组成的单词:s1,s2,…,sn。自那天起,达莎便一直被噩梦困扰。
考虑某一对整数 ⟨i,j⟩(满足 1≤i≤j≤n)。若一个字符串满足以下全部条件,则称其为一个“噩梦”:
- 它由 si 与 sj 拼接而成,即形如 sisj;
- 其长度为奇数;
- 其中恰好包含 25 个不同的字母;
- 每一个在该字符串中出现的字母,其出现次数均为奇数。
例如,若 si= "abcdefg" 且 sj= "ijklmnopqrstuvwxyz",则该对 ⟨i,j⟩ 就会产生一个噩梦。
只要达莎统计出噩梦的总数,她就能摆脱噩梦。但噩梦数量太多,因此达莎需要你的帮助。请计算不同噩梦的总数。
若两个噩梦对应的数对 ⟨i,j⟩ 不同,则称这两个噩梦不同。数对 ⟨i1,j1⟩ 与 ⟨i2,j2⟩ 被称为不同,当且仅当 i1=i2 或 j1=j2。
输入格式
The first line contains a single integer n (1≤n≤2⋅105) — the number of words.
The following n lines contain the words s1,s2,…,sn, consisting of small latin letters.
It is guaranteed that the total length of words does not exceed 5⋅106.
第一行包含一个整数 n(1≤n≤2⋅105)—— 单词的数量。
接下来的 n 行包含单词 s1,s2,…,sn,每个单词均由小写拉丁字母组成。
保证所有单词的总长度不超过 5⋅106。
输出格式
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⟩, ⟨2,5⟩, ⟨3,4⟩, ⟨6,7⟩, ⟨9,10⟩.
在第一次测试中,噩梦由以下数对产生:⟨1,3⟩、⟨2,5⟩、⟨3,4⟩、⟨6,7⟩、⟨9,10⟩。
输入解题思路,AI测评打分。不知道怎么写?