QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457569 | #8829. Aibohphobia | ucup-team1338# | WA | 0ms | 3872kb | C++20 | 709b | 2024-06-29 13:18:43 | 2024-06-29 13:18:44 |
Judging History
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)