CF1450A.Avoid Trygub

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A string bb is a subsequence of a string aa if bb can be obtained from aa 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 aa. Your task is to reorder the characters of aa so that "trygub" is not a subsequence of the resulting string.

In other words, you should find a string bb which is a permutation of symbols of the string aa and "trygub" is not a subsequence of bb.

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.

字符串 bb 是字符串 aa 的一个子序列,当且仅当 bb 可通过从 aa 中删除若干(可能为零个或全部)字符得到。例如,“xy” 是 “xzyw” 和 “xy” 的子序列,但不是 “yx” 的子序列。

给定一个字符串 aa。你的任务是重排 aa 的字符,使得 “trygub” 不是所得字符串的子序列。

换言之,你需要找到一个字符串 bb,它是字符串 aa 中所有字符的一个排列,且 “trygub” 不是 bb 的子序列。

我们有一个真正绝妙的证明:任意字符串均可被重排,使其不包含 “trygub” 作为子序列;但本题题干太短,无法容纳该证明。

输入格式

The first line contains a single integer tt (1≤t≤1001\le t\le 100) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤2001\le n\le 200) — the length of aa.

The next line contains the string aa of length nn, consisting of lowercase English letters.

第一行包含一个整数 tt(1≤t≤1001\le t\le 100)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤2001\le n\le 200)——字符串 aa 的长度。

接下来的一行包含一个长度为 nn 的字符串 aa,由小写英文字母组成。

输出格式

For each test case, output a string bb of length nn which is a permutation of characters of the string aa, and such that "trygub" is not a subsequence of it.

If there exist multiple possible strings bb, you can print any.

对于每个测试用例,输出一个长度为 nn 的字符串 bb,使得 bb 是字符串 aa 中字符的一个排列,且 "trygub" 不是 bb 的子序列。

如果存在多个可能的字符串 bb,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    3
    11
    antontrygub
    15
    bestcoordinator
    19
    trywatchinggurabruh

    输出#1

    bugyrtnotna
    bestcoordinator
    bruhtrywatchinggura

说明/提示

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".

在第一个测试用例中,“bugyrtnotna”不包含“trygub”作为子序列。它确实包含了“trygub”的所有字母,但顺序不正确,因此不是子序列。

在第二个测试用例中,我们未更改字符的顺序,因为这并非必要。

在第三个测试用例中,“bruhtrywatchinggura”包含“trygu”作为子序列,但不包含“trygub”。

输入解题思路,AI测评打分。不知道怎么写?

首页