D Swap Free
题号:NC224727
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A set of words is called swap free if there is no way to turn any word in the set into any other word in
the set by swapping only a single pair of (not necessarily adjacent) letters.

You are given a set of 𝒏 words that are all anagrams of each other. There are no duplicate letters in any
word. Find the size of the largest swap free subset of the given set. Note that it is possible for the
largest swap free subset of the given set to be the set itself.

输入描述:

The first line of input contains a single integer 𝒏 (1 ≤ 𝒏 ≤ 500).

Each of the next 𝒏 lines contains a single word 𝒘 (1 ≤ |𝒘| ≤ 26).

Every word contains only lower-case letters and no duplicate letters. All 𝒏 words are unique, and every word is an anagram of every other word.

输出描述:

Output a single integer, which is the size of the largest swap free subset.
示例1

输入

复制
6 
abc 
acb 
cab 
cba 
bac 
bca

输出

复制
3
示例2

输入

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

输出

复制
8
示例3

输入

复制
6 
ates 
east 
eats 
etas 
sate 
teas

输出

复制
4