Universal Cup Judging System

Universal Cup

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

길이가 $n$인 문자열 $s$가 주어집니다.

$1 \le i \le n$인 각 위치 $i$에 대해, $t_i$를 $s$에서 $s$의 $i$번째 문자를 삭제하고(다른 모든 문자의 상대적 순서는 유지하여) 얻은 문자열이라고 합시다.

두 문자열 $x$와 $y$에 대해, $\operatorname{lcp}(x, y)$는 두 문자열의 최장 공통 접두사의 길이를 나타냅니다. 즉, $\ell \ge 0$인 정수 중 $x$와 $y$의 처음 $\ell$개의 문자가 서로 같은($x_1 = y_1, x_2 = y_2, \dots, x_\ell = y_\ell$인) 가장 큰 정수를 의미합니다.

당신의 과제는 서로 다른 두 위치 $i$와 $j$를 선택하여 $\operatorname{lcp}(t_i, t_j)$의 값이 가능한 한 크도록 만들고, 이 가능한 최댓값을 계산하는 것입니다.

공식적으로, 다음 값을 구해야 합니다:

$$\max_{1 \le i < j \le n} \operatorname{lcp}(t_i, t_j).$$

$i$나 $j$를 출력할 필요는 없으며, $\operatorname{lcp}(t_i, t_j)$의 최댓값만 출력하면 됩니다.

입력

첫 번째 줄에는 테스트 케이스의 수를 나타내는 하나의 정수 $T$ ($1 \le T \le 2 \cdot 10^5$)가 주어집니다.

각 테스트 케이스는 문자열 $s$ ($2 \le |s| \le 5 \cdot 10^5$)가 포함된 한 줄로 이루어져 있습니다. $s$는 영어 소문자로만 이루어져 있으며, 모든 테스트 케이스에서 $|s|$의 합은 $5 \cdot 10^5$을 넘지 않음이 보장됩니다.

출력

각 테스트 케이스마다, 모든 인덱스 쌍 $i \ne j$에 대해 가능한 $\operatorname{lcp}(t_i, t_j)$의 최댓값을 나타내는 정수 하나를 각 줄에 출력합니다.

예제

예제 입력 1

5
abac
abbbb
cbacb
babcc
aa

예제 출력 1

2
4
3
4
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.