Logo
(追記) (追記ここまで)

32839번 - String Rank 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 2048 MB211996744.371%

문제

Let $w$ and $u$ be strings consisting of the English lowercase alphabet. We say that a string $u$ is a subsequence of a string $w$ if there exists a strictly increasing sequence of integers $i_1, \cdots , i_k,ドル where $|w| = n,ドル $|u| = k$ and $u[j] = w[i_j]$ for all $j = 1, \dots , k$. Here, $v[i]$ denotes the $i$-th character of the string $v$. Let $w[i:]$ denote the suffix $w[i] \cdots w[n]$. If $i > n,ドル then $w[i: ]$ is the empty string denoted by $\lambda$.

Given a nonempty string $w$ and a positive integer $k,ドル we define the $k$-set of $w$ to be the set $Q_k(w)$ of subsequences of $w$ whose lengths are 0,ドル 1, \cdots , k$. This implies that, for any string $w,ドル the empty string $\lambda$ belongs to $Q_k(w)$ by definition.

For example, when $w = $aaba, we have $Q_3($aaba$) = \{\lambda,ドル a, b, ba, ab, aa, aba, aab, aaa$\}$.

For a string $w,ドル we define the rank of $w$ to be the minimum integer $t$ such that the $t$-sets for all suffixes of $w$ are all different. In other words, the rank of $w$ is $\min\{t ≥ 1 | Q_t(w[i:]) \ne Q_t(w[j:]), ∀1 ≤ i < j ≤ n\}$.

For instance, when $w = $aaba, the 2ドル$-sets $Q_2($aba$)$ and $Q_2($aaba$)$ are equal. On the other hand, for $t = 3,ドル we have

  • $Q_3(\lambda) = \{\lambda\},ドル
  • $Q_3($a$) = \{\lambda,ドル a$\},ドル
  • $Q_3($ba$) = \{\lambda,ドル a, b, ba$\},ドル
  • $Q_3($aba$) = \{\lambda,ドル a, b, ba, ab, aa, aba$\},ドル
  • $Q_3($aaba$) = \{\lambda,ドル a, b, ba, ab, aa, aba, aab, aaa$\}$.

Therefore, the rank of the string $w = $aaba is 3ドル$.

Given a string $w,ドル write a program to output its rank.

입력

Your program is to read from standard input. The input consists of a single nonempty string $w,ドル which consists only of lowercase characters from the English alphabet. The length of the string is at most 3ドル \times 10^6$.

출력

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

제한

예제 입력 1

aabbb

예제 출력 1

3

예제 입력 2

abacb

예제 출력 2

2

예제 입력 3

azadzzadaz

예제 출력 3

4

예제 입력 4

a

예제 출력 4

1

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > 2024 ICPC Asia Seoul Regional K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /