Universal Cup Judging System

Universal Cup

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

تُعطى لك سلسلة نصية $s$ طولها $n$.

لكل موقع $i$ حيث $1 \le i \le n$، لتكن $t_i$ السلسلة النصية التي يتم الحصول عليها من $s$ عن طريق حذف الحرف ذي الترتيب $i$ من $s$ (مع الحفاظ على الترتيب النسبي لجميع الأحرف الأخرى).

لسلسلتين نصيتين $x$ و $y$، ليرمز $\operatorname{lcp}(x, y)$ إلى طول أطول بادئة مشتركة لهما، أي أكبر عدد صحيح $\ell \ge 0$ بحيث تكون أول $\ell$ أحرف من $x$ و $y$ متساوية (إذا كان $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$.

الإخراج

لكل حالة اختبار، اطبع عدداً صحيحاً واحداً في سطر منفصل، يمثل أكبر قيمة ممكنة لـ $\operatorname{lcp}(t_i, t_j)$ على جميع أزواج الأدلة $i \ne 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.