Universal Cup Judging System

Universal Cup

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

กำหนดสตริง $s$ ที่มีความยาว $n$

สำหรับแต่ละตำแหน่ง $i$ โดยที่ $1 \le i \le n$ ให้ $t_i$ เป็นสตริงที่ได้จาก $s$ โดยการลบอักขระตัวที่ $i$ ของ $s$ ออก (และรักษาลำดับสัมพัทธ์ของอักขระอื่นๆ ทั้งหมดไว้)

สำหรับสองสตริง $x$ และ $y$ ให้ $\operatorname{lcp}(x, y)$ แทน ความยาว ของอุปสรรคร่วมยาวสุด (longest common prefix) ของทั้งสองสตริง กล่าวคือ จำนวนเต็ม $\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.