题库练习 Minlexes
← 上一题 下一题 →

A13831 | Minlexes

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.

Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the following conditions are satisfied:

- for each pair $(i, i + 1)$ the inequality $0 \le i < |s| - 1$ holds;
- for each pair $(i, i + 1)$ the equality $s_i = s_{i + 1}$ holds;
- there is no index that is contained in more than one pair.

After that Lesha removes all characters on indexes contained in these pairs and the algorithm is over. Lesha is interested in the lexicographically smallest strings he can obtain by applying the algorithm to the suffixes of the given string.

输入格式

The only line contains the string $s$ ( $1 \le |s| \le 10^5$ ) — the initial string consisting of lowercase English letters only.

输出格式

In $|s|$ lines print the lengths of the answers and the answers themselves, starting with the answer for the longest suffix. The output can be large, so, when some answer is longer than $10$ characters, instead print the first $5$ characters, then "...", then the last $2$ characters of the answer.

输入输出样例

输入 #1
abcdd
输出 #1
3 abc
2 bc
1 c
0 
1 d
输入 #2
abbcdddeaaffdfouurtytwoo
输出 #2
18 abbcd...tw
17 bbcdd...tw
16 bcddd...tw
15 cddde...tw
14 dddea...tw
13 ddeaa...tw
12 deaad...tw
11 eaadf...tw
10 aadfortytw
9 adfortytw
8 dfortytw
9 fdfortytw
8 dfortytw
7 fortytw
6 ortytw
5 rtytw
6 urtytw
5 rtytw
4 tytw
3 ytw
2 tw
1 w
0 
1 o
C++ 编辑器
输入
输出