欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2039B.Shohag Loves Strings
Shohag Loves Strings
For a string , let be the number of distinct non-empty substrings of .
Shohag has a string . Help him find a non-empty string such that is a substring of and is even or state that no such string exists.
A string is a substring of a string if can be obtained from by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
Input
The first line contains a single integer () — the number of test cases.
The first and only line of each test case contains a string () consisting of lowercase English letters.
It is guaranteed that the sum of the length of over all test cases doesn't exceed .
Output
For each test case, print a non-empty string that satisfies the conditions mentioned in the statement, or if no such string exists. If there are multiple solutions, output any.
Note
In the first test case, we can set abaa because it is a substring of and the distinct non-empty substrings of are a, b, aa, ab, ba, aba, baa and abaa, so it has a total of distinct substrings which is even.
In the second test case, we can only set a but it has one distinct non-empty substring but this number is odd, so not valid.
In the third test case, the whole string contains distinct non-empty substrings, so the string itself is a valid solution.
Samples
5
dcabaac
a
youknowwho
codeforces
bangladesh
abaa
-1
youknowwho
eforce
bang
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |