欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1775A1.Gardener and the Capybaras (easy version)
Gardener and the Capybaras (easy version)
This is an easy version of the problem. The difference between the versions is that the string can be longer than in the easy version. You can only do hacks if both versions of the problem are passed.
Kazimir Kazimirovich is a Martian gardener. He has a huge orchard of binary balanced apple trees.
Recently Casimir decided to get himself three capybaras. The gardener even came up with their names and wrote them down on a piece of paper. The name of each capybara is a non-empty line consisting of letters "a" and "b".
Denote the names of the capybaras by the lines , , and . Then Casimir wrote the nonempty lines , , and in a row without spaces. For example, if the capybara's name was "aba", "ab", and "bb", then the string the gardener wrote down would look like "abaabbb".
The gardener remembered an interesting property: either the string is lexicographically not smaller than the strings and at the same time, or the string is lexicographically not greater than the strings and at the same time. In other words, either and are satisfied, or and are satisfied (or possibly both conditions simultaneously). Here denotes the lexicographic "less than or equal to" for strings. Thus, means that the strings must either be equal, or the string must stand earlier in the dictionary than the string . For a more detailed explanation of this operation, see "Notes" section.
Today the gardener looked at his notes and realized that he cannot recover the names because they are written without spaces. He is no longer sure if he can recover the original strings , , and , so he wants to find any triplet of names that satisfy the above property.

Input
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The only line of a test case contains the string () — the names of the capybaras, written together. The string consists of English letters 'a' and 'b' only.
It is guaranteed that the sum of string lengths over all test cases does not exceed .
Output
For each test case, print three strings , and on a single line, separated by spaces — names of capybaras, such that writing them without spaces results in a line . Either and , or and must be satisfied.
If there are several ways to restore the names, print any of them. If the names cannot be recovered, print ":(" (without quotes).
Note
A string is lexicographically smaller than a string if and only if one of the following holds:
- is a prefix of , but ;
- in the first position where and differ, the string has the letter '
a', and the string has the letter 'b'.
Now let's move on to the examples.
In the first test case, one of the possible ways to split the line into three lines — "b", "bb", "a".
In the third test case, we can see that the split satisfies two conditions at once (i. e., , , , and are true simultaneously).
Samples
5
bbba
aba
aaa
abba
abbb
b bb a
a b a
a a a
ab b a
a bb b
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |