logo AlgoBeat OnlineJudge
登录 注册

#214870. [ICPC 2024 Seoul R] String Rank

内存限制:2048 MiB 时间限制:500 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Let and be strings consisting of the English lowercase alphabet. We say that a string is a subsequence of a string if there exists a strictly increasing sequence of integers , where , and for all . Here, denotes the -th character of the string . Let denote the suffix . If , then is the empty string denoted by .

Given a nonempty string and a positive integer , we define the -set of to be the set of subsequences of whose lengths are . This implies that, for any string , the empty string belongs to by definition.

For example, when , we have .

For a string , we define the rank of to be the minimum integer such that the -sets for all suffixes of are all different. In other words, the rank of is .

For instance, when , the 2-sets and are equal. On the other hand, for , we have

Therefore, the rank of the string is 3.

Given a string , write a program to output its rank.

输入格式

Your program is to read from standard input. The input consists of a single nonempty string , which consists only of lowercase characters from the English alphabet. The length of the string is at most .

输出格式

Your program is to write to standard output. Print exactly one line. The line should contain a positive integer to represent the rank of the input string .

样例

样例输入 1

aabbb

样例输出 1

3

样例输入 2

abacb

样例输出 2

2

样例输入 3

azadzzadaz

样例输出 3

4

样例输入 4

a

样例输出 4

1