QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706845 | #8829. Aibohphobia | nsuDDDdd# | WA | 0ms | 3820kb | C++23 | 1.3kb | 2024-11-03 13:40:01 | 2024-11-03 13:40:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;cin>>s;
int len=s.length();
map<char,int>mp;
for(auto &i:s){
mp[i]++;
}
if(mp.size()==2){
int f=0;
for(auto[x,y]:mp){
if(y<2){f=1;}
}
if(!f){cout<<"NO"<<endl;}
else{
cout<<"YES"<<endl;
for(char i='a';i<='z';i++){
if(mp[i]==1){
cout<<i;mp[i]--;
}
}
for(char i='a';i<='z';i++){
if(mp[i]>=1){
cout<<i;mp[i]--;
}
}
for(char i='a';i<='z';i++){
if(mp[i]>=1){
string s(mp[i],i);
cout<<s;
}
}cout<<endl;
}
}
else{//YES
cout<<"YES"<<endl;
for(char i='a';i<='z';i++){
if(mp[i]>=1){
cout<<i;mp[i]--;
}
}
for(char i='a';i<='z';i++){
if(mp[i]>=1){
string s(mp[i],i);
cout<<s;
}
}cout<<endl;
}
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;cin>>t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES cipc YES entet
result:
ok Correct (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
18 qnx oooo tvttj zzzzz pvlne iijt hjhjj loo hh uq mgvgv ewwe iii kykk o mmumm aetvv xntl
output:
YES nqx YES oooo YES jtvtt YES zzzzz YES elnpv YES ijti NO YES loo YES hh YES qu YES gmvgv NO YES iii YES ykkk YES o YES ummmm YES aetvv YES lntx
result:
wrong answer Some prefix is a palindrome (test case 2)