棘手而巧妙的密码AI (CI翻译)
In his very young years the hero of our story, king Copa, decided that his private data was hidden not enough securely, what is unacceptable for the king. That's why he invented tricky and clever password (later he learned that his password is a palindrome of odd length), and coded all his data using it.
在故事主人公 Copa 国王年幼时,他认为自己的私人数据隐藏得不够安全,而这对国王来说是不可接受的。因此,他发明了一种棘手而巧妙的密码(后来他才知道,这个密码是一个长度为奇数的回文串),并用它加密了所有数据。AI (CI翻译)
Copa is afraid to forget his password, so he decided to write it on a piece of paper. He is aware that it is insecure to keep password in such way, so he decided to cipher it the following way: he cut $*x*$ characters from the start of his password and from the end of it ($*x*$ can be $0$, and $2*x*$ is strictly less than the password length). He obtained 3 parts of the password. Let's call it $*prefix*$, $*middle*$ and $*suffix*$ correspondingly, both $*prefix*$ and $*suffix*$ having equal length and $*middle*$ always having odd length. From these parts he made a string $*A* + *prefix* + *B* + *middle* + *C* + *suffix*$, where $*A*$, $*B*$ and $*C*$ are some (possibly empty) strings invented by Copa, and «$+$» means concatenation.
Copa 担心自己会忘记密码,于是决定把它写在一张纸上。他知道以这种方式保存密码并不安全,因此决定采用以下方式加密:从密码的开头和末尾各截取 $*x*$ 个字符($*x*$ 可以为 $0$,且 $2*x*$ 严格小于密码长度)。这样便得到了密码的 3 个部分。我们分别称它们为 $*prefix*$、$*middle*$ 和 $*suffix*$,其中 $*prefix*$ 和 $*suffix*$ 长度相等,而 $*middle*$ 的长度始终为奇数。接着,他将这些部分按如下方式组成一个字符串:$*A* + *prefix* + *B* + *middle* + *C* + *suffix*$,其中 $*A*$、$*B*$ 和 $*C*$ 是 Copa 自行构造的字符串(可以为空),「$+$」表示拼接。AI (CI翻译)
Many years have passed, and just yesterday the king Copa found the piece of paper where his ciphered password was written. The password, as well as the strings $*A*$, $*B*$ and $*C*$, was completely forgotten by Copa, so he asks you to find a password of maximum possible length, which could be invented, ciphered and written by Copa.
许多年过去了,就在昨天,Copa 国王找到了那张写着加密后密码的纸。Copa 已经完全忘记了密码以及字符串 $*A*$、$*B*$ 和 $*C*$,所以他请你找出一个可能由 Copa 发明并加密写下的、长度尽可能大的密码。AI (CI翻译)
Input
输入格式
AI (CI翻译)The input contains single string of small Latin letters with length from $1$ to $10^{5}$ characters.
输入包含一个由小写英文字母组成的字符串,长度在 $1$ 到 $10^{5}$ 之间。AI (CI翻译)
Output
输出格式
AI (CI翻译)The first line should contain integer $*k*$ — amount of nonempty parts of the password in your answer (
). In each of the following $*k*$ lines output two integers $*x*_{*i*}$ and $*l*_{*i*}$ — start and length of the corresponding part of the password. Output pairs in order of increasing $*x*_{*i*}$. Separate the numbers in pairs by a single space.
第一行输出整数 $*k*$,表示答案中非空密码部分的数量 (
)。接下来的 $*k*$ 行中,每行输出两个整数 $*x*_{*i*}$ 和 $*l*_{*i*}$,分别表示对应部分在输入字符串中的起始位置和长度。按 $*x*_{*i*}$ 递增的顺序输出这些数对。每对中的两个数字以一个空格分隔。AI (CI翻译)
Starting position $*x*_{*i*}$ should be an integer from $1$ to the length of the input string. All $*l*_{*i*}$ must be positive, because you should output only non-empty parts. The middle part must have odd length.
起始位置 $*x*_{*i*}$ 必须是一个介于 $1$ 和输入字符串长度之间的整数。所有 $*l*_{*i*}$ 都必须为正数,因为只应输出非空部分。中间部分的长度必须为奇数。AI (CI翻译)
If there are several solutions, output any. Note that your goal is to maximize the sum of $*l*_{*i*}$, but not to maximize $*k*$.
如果有多个解,输出任意一个。注意,你的目标是最大化 $*l*_{*i*}$ 的总和,而不是最大化 $*k*$。AI (CI翻译)
样例
abacaba
1
1 7
axbya
3
1 1
2 1
5 1
xabyczba
3
2 2
4 1
7 2
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。