QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457116 | #8829. Aibohphobia | ucup-team3510# | WA | 1ms | 3600kb | C++14 | 790b | 2024-06-29 08:11:08 | 2024-06-29 08:11:09 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int T,n,box[26];
char s[1000010];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--)
{
cin>>s+1;
n=strlen(s+1);
memset(box,0,sizeof(box));
int cnt=0;
for(int i=1;i<=n;i++)
{
cnt+=!(box[s[i]-'a']++);
}
int minn=1e9,p;
for(int i=0;i<26;i++)
{
if(box[i]&&box[i]<minn)
{
minn=box[i];
p=i;
}
}
s[n=1]=p+'a';
for(int i=0;i<26;i++)
{
if(i==p)
{
continue;
}
while(box[i]--)
{
s[++n]=i+'a';
}
}
while(--box[p])
{
s[++n]=p+'a';
}
if((cnt==1&&n>1)||cnt==2&&minn==2)
{
cout<<"NO"<<endl;
continue;
}
cout<<"YES"<<endl<<s+1<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES iccp YES neett
result:
ok Correct (5 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
18 qnx oooo tvttj zzzzz pvlne iijt hjhjj loo hh uq mgvgv ewwe iii kykk o mmumm aetvv xntl
output:
YES nqx NO YES jtttv NO YES elnpv YES jiit NO YES loo NO YES qu YES mggvv NO NO YES ykkk YES o YES ummmm YES aetvv YES lntx
result:
ok Correct (18 test cases)
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3508kb
input:
138 gcseqpht brrrzsrerr ree lgryyyh wbxkwwwwx hsihaga kvvslzgv dssd qhrqqqrqyh dfffffsfgf ssuzuuzzs rrwnyrcdnb ealelecu ccfwwwccwc emeieme xeexeswes ymkkkkpkk eimderoz lflllh lluylcll rquqrqu mllmllll cscscc ssssssssss cn llljlzlzj h kbbxahczit yxrrrrxlkr uikiakika tntnnqntw sjhxyfsy fcyyyf dbvbvdbw...
output:
YES ceghpqst YES berrrrrrsz YES ree YES ghlryyy YES bkwwwwwxx YES gaahhis YES gklsvvvz NO YES yhhqqqqqrr YES dfffffffgs YES suuuzzzss YES bcdnnrrrwy YES aceeellu YES fcccccwwww YES ieeeemm YES weeeessxx YES mkkkkkkpy YES deeimorz YES fhllll YES cllllluy YES rqqquur NO NO NO YES cn YES jlllllzzj YES ...
result:
wrong answer Some prefix is a palindrome (test case 38)