欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1342B.Binary Period
Binary Period
Let's say string has period if for all from to ( means length of string ) and is the minimum positive integer with this property.
Some examples of a period: for ="0101" the period is , for ="0000" the period is , for ="010" the period is , for ="0011" the period is .
You are given string consisting only of 0's and 1's and you need to find such string that:
- String consists only of
0's and1's; - The length of doesn't exceed ;
- String is a subsequence of string ;
- String has smallest possible period among all strings that meet conditions 1—3.
Let us recall that is a subsequence of if can be derived from by deleting zero or more elements (any) without changing the order of the remaining elements. For example, ="011" is a subsequence of ="10101".
Input
The first line contains single integer () — the number of test cases.
Next lines contain test cases — one per line. Each line contains string () consisting only of 0's and 1's.
Output
Print one string for each test case — string you needed to find. If there are multiple solutions print any one of them.
Note
In the first and second test cases, since it's already one of the optimal solutions. Answers have periods equal to and , respectively.
In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string . String has period equal to .
Samples
4
00
01
111
110
00
01
11111
1010
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |