#545. 「Nowcoder多校 2019 Day1」Substrings 2
「Nowcoder多校 2019 Day1」Substrings 2
题目描述
Two strings and are isomorphic if and only if k = l and there exists a injection such that for all . Note that a function f is injection if and only if for all .
Bobo would like to choose some strings from all substrings of the given string . Find out the maximum number of strings he may choose so that no two chosen strings are isomorphic.
输入格式
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains an integer n. The second line contains a string .
- There are at most test cases, and at most 5 of them have n > 50.
输出格式
For each test case, print an integer which denotes the result.
样例
样例输入 1
3
1 2 3
3
1 2 2
5
1 3 1 2 5
样例输出 1
3
4
7