QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#569441 | #9328. Make a Palindrome | ucup-team004# | AC ✓ | 4ms | 3976kb | C++20 | 1.1kb | 2024-09-16 22:55:28 | 2024-09-16 22:55:29 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
void solve() {
int n;
std::cin >> n;
std::string s;
std::cin >> s;
int cnt[2][26] {};
for (int i = 0; i < n; i++) {
cnt[i % 2][s[i] - 'a']++;
}
if (n % 2 == 1) {
int odd = 0;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 26; j++) {
odd += cnt[i][j] % 2;
}
}
if (odd == 1) {
std::cout << "YES\n";
} else {
std::cout << "NO\n";
}
} else {
bool ok = true;
for (int i = 0; i < 26; i++) {
if (cnt[0][i] != cnt[1][i]) {
ok = false;
}
}
if (ok) {
std::cout << "YES\n";
} else {
std::cout << "NO\n";
}
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
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: 1ms
memory: 3496kb
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: 1ms
memory: 3496kb
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: 1ms
memory: 3812kb
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: 3556kb
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: 3556kb
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: 3680kb
input:
1 100000 mzxyvnskzprgbjhsahfyeewzeethpmbpyrtqafbejpxorpztyhmirrdwfotegzasdbhgppgdbdkmqtwjohtqspjdsqscafrdaldnczldhhkvfpxbwecwdcgikjgptfrrzczwfftixubeswzyeinbrafatfzijexqscxxirqgrhyqgdiqfzesxqhyryuoiyyitccucbdxmxzuhrjaptocsljcnsjuiszsirhwgvskovzuehbnuqvflufcajgiuusbjptyrvkpnmtiewjislascbepbxdsruumlls...
output:
YES
result:
ok YES
Test #8:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
1 100000 znmdrqzffmulzjcnjlrtxnhxoqihtzxumwbkawwoemgwrzozqiomluyaxjpjnyndbjadelwbiodtmwnyamkuydechfclcgwvmghqtourhnsrtjbjpymkfudyyjigwtsevkcytntdajjvbpvynseynjprmyduwtbgbjpmqepswncezoejnkasyinhrimbvdrkncsyriotnklgzfotapjimjwfsjuibuvqnxrmpevjxaenlqpjmapsclkzkwlhazoopcvvuecnhltjqvwdyzhcrakfwgnlfouoiem...
output:
NO
result:
ok NO
Test #9:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
1 100000 cgwhxippwhuvdbruodyjrpqqmefgecxyukdsyzfqcsjwwgqsetdextqqdpogxmiaahgqlcggdmangvyzfauvhvvhaqywyvjywepcjyomcvsyuxdkeavzxftbosehlnvyeqjfpllpgkgqqupyqskbizaezsletrzqimnmcitcftryysrfjvcxinezmngecpyrigvmdyjpiefiwykmeyvukwquhatyrxmlgrqpqhbshcujkrxminygkdquohwcjbfxztxgxsnvsmvbfmmfcotrorphwcqzigupkdw...
output:
NO
result:
ok NO
Test #10:
score: 0
Accepted
time: 1ms
memory: 3584kb
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: 1ms
memory: 3532kb
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: 3680kb
input:
1 99999 yxefjxvogqbhirwagilvzafrznzyvkvqxwhrubfehhzzfrlinenoagfohqpluwadpkycnvmamhabzzzhevrzmolepomnacwqilznivlsrbgrqrtsvbscvvpwderbxrtbjxtmfgdyzbrhtmhxmqdddtbbwubezvmrrodyxjckxzxaevxxfkcjgqwlhjylkugirgvjjgabxigmfirhlbxrdkhixiklsebuwztdpxxkwtjotnifxggjirojqtitxlzyvywexlddmeuvbbxxpvohqfyrueiqgfztdeba...
output:
NO
result:
ok NO
Test #14:
score: 0
Accepted
time: 1ms
memory: 3972kb
input:
1 99999 binsgxlgtozewwucjgcvphqjgbozyeubouswcgejgrkgrhhxlgoxbfoqrwijwynyoboabvcwtuggxwscdqroogptytdqtvhowjtfomgupzzwmmbgbycdmavvslhspqsxdnlwpgniomenbxijcshzrywfyoqudxohkxirkzkvbbckfxkypqvttvlpduejsxmbhlveqshspakgoahnypjoxrfhjclblikphgobdytoeapdvrrvufspxzcrjvslecakfhrnztcvvxhlgkmgtbikpusdpstlwldlfdrl...
output:
NO
result:
ok NO
Test #15:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
1 99999 kvjrpfafnjiebwtiglqlvtlypgbnpbisnzbfblrbloywdcsmhbgmjibsyfvibsubdkfstxdqqbkdiimemqvxbixruymkxahbzysiittwnwzaplfxosttaqnpglcntrutgjiqktuqdwfptrtqxrckgzwpzzmjyctygqcnnstqofifmngbiiwhlktvpfdqwdtsyhahkkgfsohkwymrssnbvizwjvvipilixmepoadscmkdnbxfwbwwehmdhebodptkhmdmarfwlriwatpfhuiocucrqlzggzshcoww...
output:
NO
result:
ok NO
Test #16:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
1 99999 zhroloxibcnvcsxqjiuwwfpgkewzcsatejoliiobytmvmghyfywqtusuzkyftzjxahdathxzylubmibactpooeioyufurqjcnxxmzefuixrhwqngxcpsbrnacczuezksvtvhdmuuaokapbumwnanaoepfnuzyiwmmmigflqpbdkuyxkcbykflblebqtooxhrtwcnziyiiobznjkjkmbjylijusvgrywsufgtrwmueflsxryuouzeqttlpjkzuibyoiufnhibuxortfgsayflgeoaevdcmnzgpczu...
output:
NO
result:
ok NO
Test #17:
score: 0
Accepted
time: 1ms
memory: 3576kb
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