欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2098A.Vadim's Collection
Vadim's Collection
We call a phone number a beautiful if it is a string of digits, where the -th digit from the left is at least . That is, the first digit must be at least , the second at least , , with the last digit being at least .
For example, 9988776655 is a beautiful phone number, while 9099999999 is not, since the second digit, which is , is less than .
Vadim has a beautiful phone number. He wants to rearrange its digits in such a way that the result is the smallest possible beautiful phone number. Help Vadim solve this problem.
Please note that the phone numbers are compared as integers.
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 each test case contains a single string of length , consisting of digits. It is guaranteed that is a beautiful phone number.
Output
For each test case, output a single string of length — the smallest possible beautiful phone number that Vadim can obtain.
Note
In the first test case, for the first phone number 9999999999, regardless of the rearrangement of digits, the same phone number is obtained.
In the second test case, for the phone number 9988776655, it can be proven that 9876556789 is the smallest phone number that can be obtained by rearranging the digits.
Samples
4
9999999999
9988776655
9988776650
9899999999
9999999999
9876556789
9876567890
9899999999
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |