QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#457569#8829. Aibohphobiaucup-team1338#WA 0ms3872kbC++20709b2024-06-29 13:18:432024-06-29 13:18:44

Judging History

你现在查看的是最新测评结果

  • [2024-06-29 13:18:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-06-29 13:18:43]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N=500013;
int a[N];

void solve(){
    string s;
    cin>>s;
    if(s.size()==1){
        cout<<"YES\n";
        cout<<s<<'\n';
        return;
    }
    map<char,int>mp;
    for(auto c:s)mp[c]++;
    if(mp.size()==1){
        cout<<"NO\n";
        return;
    }
    string t=s;
    std::sort(t.begin(), t.end(),[&](char x,char y){
        return mp[x]==mp[y]?x<y:mp[x]<mp[y];
    });
    rotate(t.begin(),t.begin()+1,t.end());
    reverse(t.begin(), t.end());
    cout<<"YES\n";
    cout<<t<<'\n';
}

int main(){
    ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3872kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
YES
abba
YES
iccp
YES
nttee

result:

wrong answer Some prefix is a palindrome (test case 3)