时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
You are given W, a set of N words that are anagrams of each other. There are no duplicate letters in any word. A set of words S⊆W is called “swap-free” if there is no way to turn a word x∈S into another word y∈S by swapping only a single pair of (not necessarily adjacent) letters in x. Find the size of the largest swap-free set S chosen from the given set W.
输入描述:
The first line of input contains an integer N (
). Following that are N lines each with a single word. Every word contains only lowercase English letters and no duplicate letters. All N words are unique, have at least one letter, and every word is an anagram of every other word.
输出描述:
Output the size of the largest swap-free set.
示例1
输入
复制
6
abc
acb
cab
cba
bac
bca
示例2
输入
复制
11
alerts
alters
artels
estral
laster
ratels
salter
slater
staler
stelar
talers
示例3
输入
复制
6
ates
east
eats
etas
sate
teas