QOJ.ac

QOJ

Time Limit: 8 s Memory Limit: 262144 MB Total points: 100 Hackable ✓

#13123. 起泡的

Statistics

给定两个长度相同的不同字符串 $a$ 和 $b$。请检查是否存在字符串 $a$ 的某个子串 $s$,使得在原位置对 $s$ 进行循环移位后,字符串 $a$ 能够变为与字符串 $b$ 相等。

字符串 $s_1s_2 \dots s_n$ 的 $i$ 位循环移位是指形式为 $s_{n-i+1}s_{n-i+2} \dots s_n s_1s_2 \dots s_{n-i}$ 的字符串。

输入格式

第一行包含字符串 $a$,由小写拉丁字母组成。 第二行包含字符串 $b$,也由小写拉丁字母组成。 两个字符串的长度相同,且长度均不小于 $2$ 且不超过 $5 \cdot 10^5$。

输出格式

第一行输出 “YES” 或 “NO”。 如果输出 “YES”,则在第二行输出三个整数:$l$(子串起始位置,从 $1$ 开始计数)、$len$(子串长度)以及 $num$(循环移位的位数,$1 \le num \le len - 1$)。 如果存在多种解,输出满足条件的任意一组即可。

样例

样例输入 1

abacaba
aaaabbc

样例输出 1

NO

样例输入 2

abca
acba

样例输出 2

YES
2 2 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.