QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457543 | #8829. Aibohphobia | ucup-team1338# | WA | 0ms | 3840kb | C++20 | 719b | 2024-06-29 13:13:45 | 2024-06-29 13:15:02 |
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;
for(auto [h,c]:mp)while(c--)t+=h;
rotate(t.begin(),t.begin()+1,t.end()) ;
if(mp.size()==2&&t.front()==t.back()){
cout<<"NO\n";
return;
}
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: 100
Accepted
time: 0ms
memory: 3580kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES cpic YES ettne
result:
ok Correct (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3840kb
input:
18 qnx oooo tvttj zzzzz pvlne iijt hjhjj loo hh uq mgvgv ewwe iii kykk o mmumm aetvv xntl
output:
YES nxq NO YES jvttt NO YES evpnl YES itji NO YES loo NO YES qu YES gvvmg NO NO NO YES o NO YES avvte YES lxtn
result:
wrong answer Jury found the answer but participant didn't (test case 14)