QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 100

#3764. 字符串交换性

统计

Bobo 有 $n$ 个字符串 $s_1, \dots, s_n$,他想要求出满足 $s_i + s_j = s_j + s_i$ 的下标对 $(i, j)$ 的数量,其中 $i < j$。

注意,$a + b$ 表示字符串 $a$ 和 $b$ 的拼接,即先写字符串 $a$,再写字符串 $b$。

输入格式

输入包含多组测试数据,以文件结束符(EOF)终止。

每个测试数据的第一行包含一个整数 $n$。接下来的 $n$ 行中,第 $i$ 行包含一个字符串 $s_i$。

  • $1 \leq n \leq 10^5$
  • $|s_i| \leq 10^6$,$s_i$ 仅包含小写字母。
  • 所有字符串的长度之和不超过 $5 \times 10^6$。

输出格式

对于每组测试数据,输出一个整数,表示满足条件的对数。

样例

样例输入 1

2
a
ab
2
ab
ab
3
a
aa
aaa

样例输出 1

0
1
3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.