Substrings 2
题号:NC51086
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

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

输出

复制
3
4
7