QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577641#9328. Make a PalindromeAfterlife#AC ✓4ms3832kbC++20689b2024-09-20 13:39:312024-09-20 13:39:31

Judging History

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

  • [2024-09-20 13:39:31]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3832kb
  • [2024-09-20 13:39:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int c[2][26];
bool check(int *a){
    int x=0;
    for(int i=0;i<26;++i){
        x+=a[i]&1;
    }
    return x<=1;
}
bool Solve(){
    cin>>n;
    cin>>s;
    memset(c,0,sizeof(c));
    for(int i=0;i<n;++i){
        ++c[i&1][s[i]-'a'];
    }
    if(n&1){
        return check(c[0])&&check(c[1]);
    }
    else{
        for(int i=0;i<26;++i){
            if(c[0][i]^c[1][i])return false;
        }
        return true;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--){
        cout<<(Solve()?"YES\n":"NO\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
6
acbbca
6
acbbac
6
aaaaaa
7
abcacba
9
abcbcecea
1
b
2
ca
2
cc

output:

YES
NO
YES
YES
YES
YES
NO
YES

result:

ok 8 token(s): yes count is 6, no count is 2

Test #2:

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

input:

20
3
pfp
10
ccstzccctz
7
gqjyhbx
7
nrnrpyp
4
exlp
1
m
1
t
2
ec
9
iaomqaomi
6
yyzssz
9
fxhkhxnkn
10
kfftadtadk
4
uuhh
1
y
3
yuy
2
uu
9
yualaleue
8
vvzzilli
2
ss
2
dd

output:

YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 20 token(s): yes count is 16, no count is 4

Test #3:

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

input:

18
10
gicgyddtcc
2
gx
9
mkzkgxzxr
7
ayvizeh
1
e
7
tvcesec
4
yslm
4
haak
7
ssbbsjc
8
oofnvfzv
1
l
6
ggkkbb
3
dkd
3
vst
10
zbbujwmjul
4
qnti
9
prfrkxlxf
5
fhfhh

output:

NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES

result:

ok 18 token(s): yes count is 5, no count is 13

Test #4:

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

input:

41
3
uwu
16
qgrdjedqergupjup
9
wukuwexek
5
rbolm
7
ltatlfa
6
pirkgp
3
fif
18
rssbflqrtggwltbfwq
18
lhllsiiahnalisqinq
7
lllkele
20
hcwfclxtmukphzljewun
15
fgzeokzkfgbgoeb
16
llevrchllrjhvecj
15
tstmdobwtwbvtxd
12
fspfjpeiiase
3
wph
2
hh
19
jalaaaqhjacssxsbxhl
3
fkf
12
ttsvvkkmksmk
6
tthhtt
13
spexmp...

output:

YES
YES
YES
NO
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO

result:

ok 41 token(s): yes count is 27, no count is 14

Test #5:

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

input:

9580
7
titldsd
9
oolognlig
16
srrirevaaregivgs
16
rnhagyavfqygihtr
3
kcj
15
bebkykjhxvfebvy
2
ol
6
yahyah
13
auardlalaumrd
6
juuccj
20
vvkexxnxuthkddtuxhen
10
mofulsrtrf
10
tknnktiqqi
6
ejxeiv
15
ushvhkwppiwgatf
20
teetifhifhybfazzspey
7
gyfxgyf
7
qvqnheh
16
gpynxquxngpppyqu
11
ysamylyglqh
16
ndyhhm...

output:

NO
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
Y...

result:

ok 9580 token(s): yes count is 4255, no count is 5325

Test #6:

score: 0
Accepted
time: 4ms
memory: 3624kb

input:

33136
1
q
3
rku
1
r
3
vyy
2
aq
5
whehv
4
yyaa
5
yoiop
1
p
5
wltlw
1
u
1
a
3
skl
3
way
4
lltt
1
g
2
kd
4
gtto
4
dhqo
2
gg
1
c
3
dsx
4
qshh
3
xlm
3
szr
1
t
2
jx
1
p
1
b
5
wcrvq
3
mqm
1
k
3
bxb
1
w
3
ltl
2
cn
3
mjm
1
p
4
zbzz
4
jjpp
1
k
1
n
1
w
3
zmv
3
bjn
1
g
3
uru
3
isr
1
x
5
fnjhx
2
bb
4
syvf
4
sgom...

output:

YES
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
Y...

result:

ok 33136 token(s): yes count is 13206, no count is 19930

Test #7:

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

input:

1
100000
mzxyvnskzprgbjhsahfyeewzeethpmbpyrtqafbejpxorpztyhmirrdwfotegzasdbhgppgdbdkmqtwjohtqspjdsqscafrdaldnczldhhkvfpxbwecwdcgikjgptfrrzczwfftixubeswzyeinbrafatfzijexqscxxirqgrhyqgdiqfzesxqhyryuoiyyitccucbdxmxzuhrjaptocsljcnsjuiszsirhwgvskovzuehbnuqvflufcajgiuusbjptyrvkpnmtiewjislascbepbxdsruumlls...

output:

YES

result:

ok YES

Test #8:

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

input:

1
100000
znmdrqzffmulzjcnjlrtxnhxoqihtzxumwbkawwoemgwrzozqiomluyaxjpjnyndbjadelwbiodtmwnyamkuydechfclcgwvmghqtourhnsrtjbjpymkfudyyjigwtsevkcytntdajjvbpvynseynjprmyduwtbgbjpmqepswncezoejnkasyinhrimbvdrkncsyriotnklgzfotapjimjwfsjuibuvqnxrmpevjxaenlqpjmapsclkzkwlhazoopcvvuecnhltjqvwdyzhcrakfwgnlfouoiem...

output:

NO

result:

ok NO

Test #9:

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

input:

1
100000
cgwhxippwhuvdbruodyjrpqqmefgecxyukdsyzfqcsjwwgqsetdextqqdpogxmiaahgqlcggdmangvyzfauvhvvhaqywyvjywepcjyomcvsyuxdkeavzxftbosehlnvyeqjfpllpgkgqqupyqskbizaezsletrzqimnmcitcftryysrfjvcxinezmngecpyrigvmdyjpiefiwykmeyvukwquhatyrxmlgrqpqhbshcujkrxminygkdquohwcjbfxztxgxsnvsmvbfmmfcotrorphwcqzigupkdw...

output:

NO

result:

ok NO

Test #10:

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

input:

95
256
iznctqpsbnvstrctihssdgwssbbfupuiuvmnceujsdwqgctbzqzsxdmunusbzzebcbtgncottkduubqledquctwibxmaeupelkgyujiznesgmdbtgwlbrmmtxkeqdpjxjqwfoijtcbkgsebwznbosjfnjsbngzkjqukazxnshxvmtzqszenooxdlxusokvfwqnssagewsszrxtpfdmxxfnaqtzbowcqpxjlsnzsmflgfubfkqflqblodykkwjmrc
1564
fnmmggkocdvffufmpxykoransecuuox...

output:

YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
N...

result:

ok 95 token(s): yes count is 64, no count is 31

Test #11:

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

input:

4
6
aabcaa
7
aaaaabb
7
aaaabbb
4
abab

output:

NO
NO
YES
NO

result:

ok 4 token(s): yes count is 1, no count is 3

Test #12:

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

input:

1
99999
jexzipsffinrbemsrsodkltfsxxjwpaolpsvieztiocjwstjguspgrpucpybjbzphnmutqccdzycwgoojoweepvjewffynfxitqypuoycljssyltviaiikokcdeometdyxaxlgxzqhfrpmrbbjzbtvjqseedxyntrgbfwrptqvnbchjwezvhepujoonlqdqwtclpwfoctjshgavdfduthmaviatkgcyppetyxusncptefoqdrswsbdkcddhrtskqcjzbnzdqnklhkiwcyqvgkizghjgdeztglqzs...

output:

YES

result:

ok YES

Test #13:

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

input:

1
99999
yxefjxvogqbhirwagilvzafrznzyvkvqxwhrubfehhzzfrlinenoagfohqpluwadpkycnvmamhabzzzhevrzmolepomnacwqilznivlsrbgrqrtsvbscvvpwderbxrtbjxtmfgdyzbrhtmhxmqdddtbbwubezvmrrodyxjckxzxaevxxfkcjgqwlhjylkugirgvjjgabxigmfirhlbxrdkhixiklsebuwztdpxxkwtjotnifxggjirojqtitxlzyvywexlddmeuvbbxxpvohqfyrueiqgfztdeba...

output:

NO

result:

ok NO

Test #14:

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

input:

1
99999
binsgxlgtozewwucjgcvphqjgbozyeubouswcgejgrkgrhhxlgoxbfoqrwijwynyoboabvcwtuggxwscdqroogptytdqtvhowjtfomgupzzwmmbgbycdmavvslhspqsxdnlwpgniomenbxijcshzrywfyoqudxohkxirkzkvbbckfxkypqvttvlpduejsxmbhlveqshspakgoahnypjoxrfhjclblikphgobdytoeapdvrrvufspxzcrjvslecakfhrnztcvvxhlgkmgtbikpusdpstlwldlfdrl...

output:

NO

result:

ok NO

Test #15:

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

input:

1
99999
kvjrpfafnjiebwtiglqlvtlypgbnpbisnzbfblrbloywdcsmhbgmjibsyfvibsubdkfstxdqqbkdiimemqvxbixruymkxahbzysiittwnwzaplfxosttaqnpglcntrutgjiqktuqdwfptrtqxrckgzwpzzmjyctygqcnnstqofifmngbiiwhlktvpfdqwdtsyhahkkgfsohkwymrssnbvizwjvvipilixmepoadscmkdnbxfwbwwehmdhebodptkhmdmarfwlriwatpfhuiocucrqlzggzshcoww...

output:

NO

result:

ok NO

Test #16:

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

input:

1
99999
zhroloxibcnvcsxqjiuwwfpgkewzcsatejoliiobytmvmghyfywqtusuzkyftzjxahdathxzylubmibactpooeioyufurqjcnxxmzefuixrhwqngxcpsbrnacczuezksvtvhdmuuaokapbumwnanaoepfnuzyiwmmmigflqpbdkuyxkcbykflblebqtooxhrtwcnziyiiobznjkjkmbjylijusvgrywsufgtrwmueflsxryuouzeqttlpjkzuibyoiufnhibuxortfgsayflgeoaevdcmnzgpczu...

output:

NO

result:

ok NO

Test #17:

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

input:

14
6047
cvxcsggkjxpswvgeizefcrkcabnfutdvwxyduwatlagagnbmyfgaqwonfuifmjdjbyuixjtnwutxloswmuobcgrkkevahmbkvrsbjxrobkrgnletxgeopcafeyzoskglzraetxqncqtuqgknpmvwvuzvtqxxrrgplvtcqcjiuwgvnferpnjjgqhudwtxzkvvmgblfzzcduyaufoakithjjwgwoqcurkowgtspcqijsetzobnnuznyumkyexexgcwwkmmcqfcxjbtvcavbwmotpqxbitacwjptkur...

output:

NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
YES

result:

ok 14 token(s): yes count is 5, no count is 9