A15842 | Dasha and Nightmares
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $s_1, s_2, \ldots, s_n$ to the lyceum. Since that day, Dasha has been tormented by nightmares.
Consider some pair of integers $\langle i, j \rangle$ ( $1 \le i \le j \le n$ ). A nightmare is a string for which it is true:
- It is obtained by concatenation $s_{i}s_{j}$ ;
- 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 $s_i=$ "abcdefg" and $s_j=$ "ijklmnopqrstuvwxyz", the pair $\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 $\langle i, j \rangle$ are different. The pairs $\langle i_1, j_1 \rangle$ and $\langle i_2, j_2 \rangle$ are called different if $i_1 \neq i_2$ or $j_1 \neq j_2$ .
Consider some pair of integers $\langle i, j \rangle$ ( $1 \le i \le j \le n$ ). A nightmare is a string for which it is true:
- It is obtained by concatenation $s_{i}s_{j}$ ;
- 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 $s_i=$ "abcdefg" and $s_j=$ "ijklmnopqrstuvwxyz", the pair $\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 $\langle i, j \rangle$ are different. The pairs $\langle i_1, j_1 \rangle$ and $\langle i_2, j_2 \rangle$ are called different if $i_1 \neq i_2$ or $j_1 \neq j_2$ .
输入格式
The first line contains a single integer $n$ ( $1 \le n \le 2 \cdot 10^5$ ) — the number of words.
The following $n$ lines contain the words $s_1, s_2, \ldots, s_n$ , consisting of small latin letters.
It is guaranteed that the total length of words does not exceed $5 \cdot 10^6$ .
The following $n$ lines contain the words $s_1, s_2, \ldots, s_n$ , consisting of small latin letters.
It is guaranteed that the total length of words does not exceed $5 \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 $\langle 1, 3 \rangle$ , $\langle 2, 5 \rangle$ , $\langle 3, 4 \rangle$ , $\langle 6, 7 \rangle$ , $\langle 9, 10 \rangle$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted