QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692570#9328. Make a Palindromelytqwq#AC ✓7ms3928kbC++14672b2024-10-31 14:43:122024-10-31 14:43:22

Judging History

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

  • [2024-10-31 14:43:22]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:3928kb
  • [2024-10-31 14:43:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int s[N];
char a[N];
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		for(int i=0;i<=60;i++)s[i]=0;
		int n;
		scanf("%d",&n);
		scanf("%s",a+1);
		for(int i=1;i<=n;i++){
			s[a[i]-'a']+=(i%2==1?1:-1);
		}
		int no=1;
		for(int i=0;i<=60;i++)if(s[i]!=0){
			no=0;
		}
		if(n%2==0){
			if(no)printf("YES\n");
			else printf("NO\n");
		}
		else{
			for(int i=0;i<=60;i++)s[i]=0;
			for(int i=1;i<=n;i++){
				s[a[i]-'a'+27*(i%2==0)]++;
			}
			int no=1;
			for(int i=0;i<=60;i++)if(s[i]%2==1){
				no--;
			}
			if(no<0)printf("NO\n");
			else printf("YES\n");
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3808kb

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: 3880kb

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: 3836kb

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: 3772kb

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: 3ms
memory: 3820kb

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: 7ms
memory: 3820kb

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: 3916kb

input:

1
100000
mzxyvnskzprgbjhsahfyeewzeethpmbpyrtqafbejpxorpztyhmirrdwfotegzasdbhgppgdbdkmqtwjohtqspjdsqscafrdaldnczldhhkvfpxbwecwdcgikjgptfrrzczwfftixubeswzyeinbrafatfzijexqscxxirqgrhyqgdiqfzesxqhyryuoiyyitccucbdxmxzuhrjaptocsljcnsjuiszsirhwgvskovzuehbnuqvflufcajgiuusbjptyrvkpnmtiewjislascbepbxdsruumlls...

output:

YES

result:

ok YES

Test #8:

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

input:

1
100000
znmdrqzffmulzjcnjlrtxnhxoqihtzxumwbkawwoemgwrzozqiomluyaxjpjnyndbjadelwbiodtmwnyamkuydechfclcgwvmghqtourhnsrtjbjpymkfudyyjigwtsevkcytntdajjvbpvynseynjprmyduwtbgbjpmqepswncezoejnkasyinhrimbvdrkncsyriotnklgzfotapjimjwfsjuibuvqnxrmpevjxaenlqpjmapsclkzkwlhazoopcvvuecnhltjqvwdyzhcrakfwgnlfouoiem...

output:

NO

result:

ok NO

Test #9:

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

input:

1
100000
cgwhxippwhuvdbruodyjrpqqmefgecxyukdsyzfqcsjwwgqsetdextqqdpogxmiaahgqlcggdmangvyzfauvhvvhaqywyvjywepcjyomcvsyuxdkeavzxftbosehlnvyeqjfpllpgkgqqupyqskbizaezsletrzqimnmcitcftryysrfjvcxinezmngecpyrigvmdyjpiefiwykmeyvukwquhatyrxmlgrqpqhbshcujkrxminygkdquohwcjbfxztxgxsnvsmvbfmmfcotrorphwcqzigupkdw...

output:

NO

result:

ok NO

Test #10:

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

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: 3848kb

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: 3924kb

input:

1
99999
jexzipsffinrbemsrsodkltfsxxjwpaolpsvieztiocjwstjguspgrpucpybjbzphnmutqccdzycwgoojoweepvjewffynfxitqypuoycljssyltviaiikokcdeometdyxaxlgxzqhfrpmrbbjzbtvjqseedxyntrgbfwrptqvnbchjwezvhepujoonlqdqwtclpwfoctjshgavdfduthmaviatkgcyppetyxusncptefoqdrswsbdkcddhrtskqcjzbnzdqnklhkiwcyqvgkizghjgdeztglqzs...

output:

YES

result:

ok YES

Test #13:

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

input:

1
99999
yxefjxvogqbhirwagilvzafrznzyvkvqxwhrubfehhzzfrlinenoagfohqpluwadpkycnvmamhabzzzhevrzmolepomnacwqilznivlsrbgrqrtsvbscvvpwderbxrtbjxtmfgdyzbrhtmhxmqdddtbbwubezvmrrodyxjckxzxaevxxfkcjgqwlhjylkugirgvjjgabxigmfirhlbxrdkhixiklsebuwztdpxxkwtjotnifxggjirojqtitxlzyvywexlddmeuvbbxxpvohqfyrueiqgfztdeba...

output:

NO

result:

ok NO

Test #14:

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

input:

1
99999
binsgxlgtozewwucjgcvphqjgbozyeubouswcgejgrkgrhhxlgoxbfoqrwijwynyoboabvcwtuggxwscdqroogptytdqtvhowjtfomgupzzwmmbgbycdmavvslhspqsxdnlwpgniomenbxijcshzrywfyoqudxohkxirkzkvbbckfxkypqvttvlpduejsxmbhlveqshspakgoahnypjoxrfhjclblikphgobdytoeapdvrrvufspxzcrjvslecakfhrnztcvvxhlgkmgtbikpusdpstlwldlfdrl...

output:

NO

result:

ok NO

Test #15:

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

input:

1
99999
kvjrpfafnjiebwtiglqlvtlypgbnpbisnzbfblrbloywdcsmhbgmjibsyfvibsubdkfstxdqqbkdiimemqvxbixruymkxahbzysiittwnwzaplfxosttaqnpglcntrutgjiqktuqdwfptrtqxrckgzwpzzmjyctygqcnnstqofifmngbiiwhlktvpfdqwdtsyhahkkgfsohkwymrssnbvizwjvvipilixmepoadscmkdnbxfwbwwehmdhebodptkhmdmarfwlriwatpfhuiocucrqlzggzshcoww...

output:

NO

result:

ok NO

Test #16:

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

input:

1
99999
zhroloxibcnvcsxqjiuwwfpgkewzcsatejoliiobytmvmghyfywqtusuzkyftzjxahdathxzylubmibactpooeioyufurqjcnxxmzefuixrhwqngxcpsbrnacczuezksvtvhdmuuaokapbumwnanaoepfnuzyiwmmmigflqpbdkuyxkcbykflblebqtooxhrtwcnziyiiobznjkjkmbjylijusvgrywsufgtrwmueflsxryuouzeqttlpjkzuibyoiufnhibuxortfgsayflgeoaevdcmnzgpczu...

output:

NO

result:

ok NO

Test #17:

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

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