QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#457546#8829. Aibohphobiaucup-team1525#RE 26ms3720kbC++201.3kb2024-06-29 13:14:122024-06-29 13:15:16

Judging History

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

  • [2024-06-29 13:15:16]
  • 评测
  • 测评结果:RE
  • 用时:26ms
  • 内存:3720kb
  • [2024-06-29 13:14:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int t;
char s[N];
int cnt[30],ord[30];
bool cmp(int x,int y)
{
    return cnt[x]>cnt[y];
}
int main()
{
    scanf("%d",&t);
    while (t--)
    {
        scanf("%s",s);
        int n=strlen(s);
        for (int i=0;i<=25;++i)
        {
            cnt[i]=0;
            ord[i]=i;
        }
        for (int i=0;i<n;++i)
            cnt[s[i]-'a']++;
        sort(ord,ord+26,cmp);
        if (cnt[ord[2]]==0)
        {
            if (n==1)
            {
                puts("YES");
                putchar('a'+ord[0]);
                putchar('\n');
                continue;
            }
            if (cnt[ord[1]]==1)
            {
                puts("YES");
                putchar('a'+ord[1]);
                for (int i=1;i<=cnt[ord[0]];++i)
                    putchar('a'+ord[0]);
                putchar('\n');
                continue;
            }
            puts("NO");
            continue;
        }
        puts("YES");
        while (cnt[ord[0]])
        {
            for (int i=0;i<26;++i)
                if (cnt[ord[i]])
                {
                    putchar('a'+ord[i]);
                    --cnt[ord[i]];
                }
        }
        putchar('\n');
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
NO
YES
cipc
YES
etnet

result:

ok Correct (5 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

18
qnx
oooo
tvttj
zzzzz
pvlne
iijt
hjhjj
loo
hh
uq
mgvgv
ewwe
iii
kykk
o
mmumm
aetvv
xntl

output:

YES
xqn
NO
YES
tvjtt
NO
YES
evlnp
YES
itji
NO
YES
loo
NO
YES
qu
YES
vgmvg
NO
NO
YES
ykkk
YES
o
YES
ummmm
YES
vetav
YES
xtln

result:

ok Correct (18 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

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
ceghtsqp
YES
rbzserrrrr
YES
ree
YES
yghlryy
YES
wxbkwxwww
YES
hagisha
YES
vzgsklvv
NO
YES
qhryqhrqqq
YES
fdgsffffff
YES
zuszuszus
YES
rnbywcdrnr
YES
elcuaele
YES
cwfcwcwcwc
YES
emiemee
YES
exswexsee
YES
kympkkkkk
YES
ezdimroe
YES
lfhlll
YES
lcyullll
YES
qurqurq
NO
NO
NO
YES
nc
YES
lzjlzjlll
YES
...

result:

ok Correct (138 test cases)

Test #4:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

683
ufvvflppuvfu
ccgchccndvvtqcu
dqgqdddrgddjid
iiiiiiiiiiimiin
dqsiejxqqqq
kkkjzkkzkkvvkkk
aaeamagwzwagmni
bgddgdbbggdgb
xebbzbqrrx
tyxkqsyyclhyx
bjpdrrrrrrjrv
qzzqzzzqqq
ykgaykqyqqk
iefeeetaeeee
qqbabbfbslxfh
ovvczvcdcvecb
ieiiiaiqiiibii
hxeeeexeexxxxh
jxxxjxjrjjjx
jjzjjrzgqnjyj
rqqtzzptqopq
wbsyv...

output:

YES
fvuplfvupfvu
YES
cvdghutnqcvcccc
YES
dgqijrdgqddddd
YES
imniiiiiiiiiiii
YES
qdexijsqqqq
YES
kzvjkzvkkkkkkkk
YES
awmgnzieawmgaaa
YES
gbdgbdgbdgbdg
YES
bxrzqebxrb
YES
yxchtklsqyxyy
YES
rjbdvprjrrrrr
NO
YES
ykqgaykqykq
YES
efitaeeeeeee
YES
bfqaxhlsbfqbb
YES
cvbzodecvcvcv
YES
ibaeqiiiiiiiii
YES
xehx...

result:

ok Correct (683 test cases)

Test #5:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

2713
ahrfzkzqahzahbqahzzu
vwwwdpdsopmwmdmss
zhkzhzjefkvnjfbxxbk
oawqeraqvqoqqg
eeeeedsxddeehzeehzee
afrzcqrhdqikqcvqcakj
xqkkkzqquqqkqqkdd
urtrttjuruttutruutut
mktgalyydawhgtcka
qjhjjxxqhhqxqx
fkfzfkffkfkkfffkkfz
byyyqbbboboyqqoobb
eyeyylrleeylerllrly
ggfgzqgyqvqlehnq
rrsjrrjrrjjjjrrrzrr
qyqqyycrqrr...

output:

YES
zahqburkfzahqzahzahz
YES
wdsmpvowdsmpwdsmw
YES
zkbxjhfenvzkbxjhfzk
YES
qaoewgvrqaoqqq
YES
edzhxsedzhedeeeeeeee
YES
qcrakjvihfdzqcrakqcq
YES
qkdzxuqkdqkqkqkqq
YES
turjturturturtututut
YES
aytgkcdhwlmaytgka
YES
xqhjxqhjxqhjxq
YES
fkzfkzfkfkfkfkfkfff
YES
byoqbyoqbyoqbyobbb
YES
lyerlyerlyerlyelyel
Y...

result:

ok Correct (2713 test cases)

Test #6:

score: 0
Accepted
time: 26ms
memory: 3584kb

input:

35444
vvgmvmmhtmgmmhvfhhhmhmqmqhmhhvf
aiiaaaaipaiapsspcppaaappppypapa
qgprgwugggggiqargigggugefgarg
ssikskkmiisksqsssssssn
dtvmryhhtikrrhmmhmmymrmimbvpvv
cpbpprllqzletlllplugkxf
sbpkbkbsptsbkkkbtbtsktkb
ngvnnvnvgcgcnvnngnnnnvgn
mhhyltymyjhynhhyymtyuuuyydjyyys
vlbkkgmtekutxaltkltttkkcakttlkl
njemezmg...

output:

YES
mhvfgqtmhvfgqmhvmhvmhvmhmhmhmhm
YES
apiscyapisapiapiapapapapapapapa
YES
griqaufwepgriqaugrggggggggggg
YES
skimnqskiskiskssssssss
YES
mrvhitykdpbmrvhitymrvhmrvhmmmm
YES
lpbzxutrqkgfeclplplplll
YES
bktspbktspbktsbktsbkbkbk
YES
ngvcngvcngvngvngvnnnnnnn
YES
yhumjtdlnsyhumjtyhumyhyhyyyyyyy
YES
ktlabc...

result:

ok Correct (35444 test cases)

Test #7:

score: -100
Runtime Error

input:

1
lllvrvrqtekpyfwztplrzmkfmlvllvjmzffllrmemmyjmlllwbiruatutvvumfttuemtjvmfvmjktlfzwmllfitqtvjtqftvergkqtebzjmwtvfjklklgjjevuuqrjzltrutklzytzvjyjuzlvjlivilvwtztijfrmvfkmfkiuxrtpftibbrlzvltbljbjtiqlzzjtyvljklvluutzqjvltenvtjlmtjyejvvlverflbvmkvjfwtlvrvmpbtpllvpbklqkulezkmrmltljvtklvitqelmvqvvfqfofkfyu...

output:


result: