QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706845#8829. AibohphobiansuDDDdd#WA 0ms3820kbC++231.3kb2024-11-03 13:40:012024-11-03 13:40:02

Judging History

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

  • [2024-11-03 13:40:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-11-03 13:40:01]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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)