QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100

#10034. 披萨餐厅

Statistics

给定 $n$ 个字符串 $s_1, s_2, \dots, s_n$。请找到两个不同的下标 $x$ 和 $y$ 以及一个正整数 $k$,使得字符串 $\underbrace{s_x s_y s_y \dots s_y}_{k \text{ 次 } s_y}$ 是一个长度不超过 $6 \cdot 10^6$ 的回文串,或者报告不存在这样的解。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 10^5$)。 接下来 $n$ 行,每行包含一个字符串 $s_i$ ($1 \le |s_i| < 10^6$)。字符串由小写英文字母组成。所有字符串的总长度不超过 $10^6$。

输出格式

如果没有解,输出 “No”(不含引号)。 否则,第一行输出 “Yes”(不含引号)。第二行输出三个整数 $x, y$ 和 $k$ ($1 \le x, y \le n, x \neq y, k \ge 1, |s_x| + k \cdot |s_y| \le 6 \cdot 10^6$)。如果存在多组解,输出其中任意一组即可。

样例

输入 1

2
aa
aa

输出 1

Yes
1 2 1

输入 2

4
a
bb
bcb
cdc

输出 2

No

输入 3

2
ap
papajoj

输出 3

Yes
2 1 2

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.