欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1450A.Avoid Trygub
Avoid Trygub
A string is a subsequence of a string if can be obtained from by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "yx".
You are given a string . Your task is to reorder the characters of so that "trygub" is not a subsequence of the resulting string.
In other words, you should find a string which is a permutation of symbols of the string and "trygub" is not a subsequence of .
We have a truly marvelous proof that any string can be arranged not to contain "trygub" as a subsequence, but this problem statement is too short to contain it.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of .
The next line contains the string of length , consisting of lowercase English letters.
Output
For each test case, output a string of length which is a permutation of characters of the string , and such that "trygub" is not a subsequence of it.
If there exist multiple possible strings , you can print any.
Note
In the first test case, "bugyrtnotna" does not contain "trygub" as a subsequence. It does contain the letters of "trygub", but not in the correct order, so it is not a subsequence.
In the second test case, we did not change the order of characters because it is not needed.
In the third test case, "bruhtrywatchinggura" does contain "trygu" as a subsequence, but not "trygub".
Samples
3
11
antontrygub
15
bestcoordinator
19
trywatchinggurabruh
bugyrtnotna
bestcoordinator
bruhtrywatchinggura
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |