A. Avoid Trygub(水题)Codeforces Global Round 12

原题链接: http://codeforces.com/contest/1450/problem/A

在这里插入图片描述
测试样例

input
3
11
antontrygub
15
bestcoordinator
19
trywatchinggurabruh
output
bugyrtnotna
bestcoordinator
bruhtrywatchinggura

题意: 给定一个字符串,重新排列该字符串,使得“trygub”不是它的子串。

解题思路: 水题一道,为了避免不出现,我们可以按字典序重新排列字符串即可。

AC代码

/*
*blog:https://blog.csdn.net/hzf0701
*邮箱:unique_powerhouse@qq.com
*注:文章若有任何问题请私信我或评论区留言,谢谢支持。
*/
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)

using namespace std;

typedef long long ll;
const int maxn=2e5+10;//数组所开最大值
const int mod=1e9+7;//模
const int inf=0x3f3f3f3f;//无穷大

ll t,n;
string s;
void solve(){
    sort(s.begin(),s.end());
    cout<<s<<endl;
}
int main(){
    while(cin>>t){
        while(t--){
            cin>>n>>s;
            solve();
        }
    }
    return 0;
}

posted @ 2022-03-26 16:49  unique_pursuit  阅读(21)  评论(0)    收藏  举报