QOJ.ac

QOJ

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

#5726. 纠错

统计

给定一个包含 $N$ 个单词的集合 $W$,这些单词互为变位词(anagrams)。每个单词中都没有重复的字母。如果一个单词集合 $S \subseteq W$ 满足:对于集合中的任意两个单词 $x, y \in S$($x$ 可以等于 $y$),都无法通过交换 $x$ 中的某一对(不一定相邻)字母得到 $y$,则称该集合 $S$ 为“无交换”(swap-free)集合。请找出从给定集合 $W$ 中选出的最大的无交换集合 $S$ 的大小。

输入格式

输入的第一行包含一个整数 $N$ ($1 \le N \le 500$)。接下来有 $N$ 行,每行包含一个单词。每个单词仅包含小写英文字母且没有重复字母。所有 $N$ 个单词都是唯一的,至少包含一个字母,且每个单词都是其他所有单词的变位词。

输出格式

输出最大的无交换集合的大小。

样例

输入 1

6
abc
acb
cab
cba
bac
bca

输出 1

3

输入 2

11
alerts
alters
artels
estral
laster
ratels
salter
slater
staler
stelar
talers

输出 2

8

输入 3

6
ates
east
eats
etas
sate
teas

输出 3

4

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.