QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353056 | #7994. 勿蹖宠物 | rzh123 | AC ✓ | 435ms | 18400kb | C++14 | 2.9kb | 2024-03-13 20:20:43 | 2024-03-13 20:20:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N=337,L=1005,P=1e9+7;
constexpr int B=37;
int n,m,len[N],bp[L];
string s[N];
basic_string<int> ha[N],ah[N];
int* f[605][2][N],ans;
// 短的一端长度 i,左/右更短,长的从 s[j][k] 开始
inline void add(int &a,int b){
if((a+=b)>=P) a-=P;
}
inline void makeha(const string &s,basic_string<int> &ha,basic_string<int> &ah){
ha.resize(s.size()),ah.resize(s.size());
for(unsigned i{0};i<s.size();++i){
if(i>0) ha[i]=int((1ll*ha[i-1]*B+(s[i]-'a'))%P);
else ha[i]=s[i]-'a';
}
for(int i{(int)s.size()-1};i>=0;--i){
if(i+1<(int)s.size()) ah[i]=int((1ll*ah[i+1]*B+(s[i]-'a'))%P);
else ah[i]=s[i]-'a';
}
}
inline int getha(const basic_string<int> &ha,int l,int r){
int v=ha[r];
if(l>0) v=int((v-1ll*ha[l-1]*bp[r-l+1]%P+P)%P);
return v;
}
inline int getrevha(const basic_string<int> &ah,int l,int r){
int v=ah[l];
if(r+1<(int)ah.size()) v=int((v-1ll*ah[r+1]*bp[r-l+1]%P+P)%P);
return v;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int i{1};i<=n;++i){
string t; cin>>t;
len[i]=(int)t.size();
s[i]=t;
makeha(s[i],ha[i],ah[i]);
}
for(int i{0};i<605;++i) for(int j:{0,1}) for(int k{1};k<=n;++k) f[i][j][k]=new int[len[k]+5]{};
bp[0]=1; for(int i{1};i<605;++i) bp[i]=int(1ll*bp[i-1]*B%P);
for(int i{1};i<=n;++i){
if(len[i]>m) continue;
int sz=len[i];
if(!(m&1)){
for(int j{0};j<sz;++j){
int mn{min(j+1,sz-j-1)};
if(getrevha(ah[i],j-mn+1,j)!=getha(ha[i],j+1,j+mn)) continue;
if(j+1>sz-j-1) f[mn][1][i][j-mn]=1;
else f[mn][0][i][j+mn+1]=1;
}
}
else{
for(int j{0};j<sz;++j){
int mn{min(j,sz-j-1)};
if(getrevha(ah[i],j-mn,j-1)!=getha(ha[i],j+1,j+mn)) continue;
if(j>sz-j-1) f[mn][1][i][j-mn-1]=1;
else f[mn][0][i][j+mn+1]=1;
}
}
}
for(int i{0};i<=m/2;++i){
for(int j:{0,1}){
for(int k{1};k<=n;++k){
for(int l{0};l<=len[k];++l){
if(!f[i][j][k][l]) continue;
if(i==m/2){
if(j==0&&l==len[k]) add(ans,f[i][j][k][l]);
continue;
}
int rest{0};
if(j==0) rest=len[k]-l;
else rest=l+1;
for(int t{1};t<=n;++t){
if(i+len[t]>m/2) continue;
if(j==0){
if(rest<len[t]){
if(getrevha(ah[t],len[t]-rest,len[t]-1)==getha(ha[k],l,len[k]-1))
add(f[i+rest][!j][t][len[t]-rest-1],f[i][j][k][l]);
}
else{
if(getrevha(ah[t],0,len[t]-1)==getha(ha[k],l,l+len[t]-1))
add(f[i+len[t]][j][k][l+len[t]],f[i][j][k][l]);
}
}
else{
if(rest<=len[t]){
if(getrevha(ah[t],0,rest-1)==getha(ha[k],0,l))
add(f[i+rest][!j][t][rest],f[i][j][k][l]);
}
else{
if(getrevha(ah[t],0,len[t]-1)==getha(ha[k],l-len[t]+1,l))
add(f[i+len[t]][j][k][l-len[t]],f[i][j][k][l]);
}
}
}
}
}
}
}
cout<<ans<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7172kb
input:
7 9 cats eel eve evil lee olive stack
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 6864kb
input:
2 2 a aa
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 2ms
memory: 7160kb
input:
6 12 aa aab no on pets step
output:
43
result:
ok single line: '43'
Test #4:
score: 0
Accepted
time: 5ms
memory: 7740kb
input:
26 1000 a b c d e f g h i j k l m n o p q r s t u v w x y z
output:
710955506
result:
ok single line: '710955506'
Test #5:
score: 0
Accepted
time: 0ms
memory: 10756kb
input:
33 18 zrkodfkhhkfdokrzo ytcbwrgyygrwbcty makgiybggbyigkamc aptmvovgccgvovmtpa yydxdzhhhhzdxdyy iadqfexoxacojythvk iagcfiwlaalwifcgai rtfzhddzzddhzftrm vkreigbdyxfiuvyqid mbcgnvrvvrvngcbmc lywbtspuyyupstbwyl bmjxalsyyslaxjmb jrbminaooanimbrj wwrajerkkrejarww grocaiqccqiacorg efvibgurrugbivfec ilyzrft...
output:
9
result:
ok single line: '9'
Test #6:
score: 0
Accepted
time: 0ms
memory: 11136kb
input:
33 18 babbababbbbababbab abbabaabaabaababba aaabbbaabbaabbbaaa aaabaababbabaabaaa ababbaabbbbaabbaba baababbbbbbbbabaab aababbbaaaabbbabaa bbbbbabaaaababbbbb aabbbaaaaaaaabbbaa aabbbabaaaababbbaa bbabbaabaabaabbabb aababbabbbbabbabaa baaaaaabbbbaaaaaab aaabababaabababaaa bbaabbaaaaaabbaabb bbbababab...
output:
33
result:
ok single line: '33'
Test #7:
score: 0
Accepted
time: 0ms
memory: 11120kb
input:
33 18 babababaaaabababa abbbabbaaaabbabbba bbaaaabbaabbaaaabb baabbbbaaaabbbbaab abbbaababbabaabbb aaababbabbabbabaaa abbbbbbabbabbbbbba bbaabaaaaaaaabaabb aaaaabaaaaaabaaaaa abbbaabbbbbbaabbba abbbbaaaaaaaabbbba bbbbbbbbaabbbbbbbb baabaabbbbaabaab bbaababaaaababaabb baaabaabbbbaabaaab bbaaaabbbbbba...
output:
27
result:
ok single line: '27'
Test #8:
score: 0
Accepted
time: 0ms
memory: 10876kb
input:
33 18 bbbababaabababbb abaabaaabbaaabaaba aaabbbbbbaaaabbbab aaabbababbababbaaa abbaaabaabaaaaabbb abababaaaaaabababa bbabaaaaaaaababb bababbaaaaaabbaba aaaaababbbbabaaaa aaabaababbabaabaa abbbbbabbabbbbbaa abbbbbaabbaabbbbba abaaabbabaabbbabbb aabaabbbaabbbaabaa aaababbbbbabababaa abaaabbaabbaaabab...
output:
8
result:
ok single line: '8'
Test #9:
score: 0
Accepted
time: 319ms
memory: 18104kb
input:
199 999 lbl buei ieub uw wu impv vpmi yrek kery cw wc hjs sjh bct tcb up pu wh hw ftn ntf iv vi ejpj jpje qjgh hgjq kvny ynvk xo ox pr rp sdh hds go og qw wq bgt tgb czwk kwzc coqr rqoc af fa ms sm gs sg hnz znh rugm mgur lak kal xlv vlx na an fdoe eodf oixg gxio mb bm bjt tjb bto otb oxq qxo tg gt ...
output:
810133722
result:
ok single line: '810133722'
Test #10:
score: 0
Accepted
time: 323ms
memory: 18072kb
input:
198 999 eme hm mh msi ism ig gi kmm mmk nkxq qxkn uv vu mgj jgm zyap payz xz zx oi io spe eps kr rk pqp pvyw wyvp pk kp nrin nirn ehj jhe vb bv fnzq qznf lem mel lxek kexl sy ys smcs scms xaq qax zdsn nsdz pudp pdup zt tz op po oe eo cea aec df fd om mo zr rz wabq qbaw ehde edhe cq qc utd dtu rj jr ...
output:
165733504
result:
ok single line: '165733504'
Test #11:
score: 0
Accepted
time: 432ms
memory: 17404kb
input:
187 999 dcd ede bbb ga ag aead daea ec ce bf fb ffg gff bde edb efc cfe bb aged dega cea aec accg gcca cge egc gb bg cfcg gcfc fgg ggf bffc cffb fg gf bac cab adfb bfda ff adfe efda ggaf fagg age ega cb bc acbd dbca bbdd ddbb ee fegg ggef gca acg ffab baff gdb bdg gee eeg babb bbab bfe efb be eb ddb...
output:
359867349
result:
ok single line: '359867349'
Test #12:
score: 0
Accepted
time: 435ms
memory: 17580kb
input:
189 999 beb dfd fbf bcb fef aaa gdg eg ge ebc cbe eaf fae bf fb daa aad caec ceac df fd eca ace gdge egdg adfb bfda dda add bcdc cdcb ed de ggaa aagg bge egb fgf efd dfe acbb bbca ac ca bg gb dbge egbd da ad gbf fbg ccae eacc eaa aae cea aec gc cg feg gef eebg gbee ccga agcc ag ga aa bb gdf fdg bagd...
output:
559580115
result:
ok single line: '559580115'
Test #13:
score: 0
Accepted
time: 350ms
memory: 18400kb
input:
201 1000 cni inc shxg gxhs xfpi ipfx ymt tmy sx xs bqe eqb mwg gwm mb bm lbtj jtbl dx xd srra arrs gmyd dymg ot to zrv vrz eojb bjoe he eh fq qf vrc crv wdev vedw ey ye nrh hrn kuee eeuk syy yys xw wx hjrn nrjh btyx xytb cdop podc uj ju il li kief feik ao oa hhfc cfhh ev ve jbs sbj plle ellp iz zi q...
output:
56283946
result:
ok single line: '56283946'
Test #14:
score: 0
Accepted
time: 318ms
memory: 17860kb
input:
195 1000 fz zf qry yrq yypc cpyy bvx xvb gwd dwg iois sioi uw wu lvvh hvvl tp pt xbzk kzbx mdqo oqdm ism msi io oi ab ba qv vq eq qe wz zw pgz zgp as sa goj jog jcqe eqcj fv vf vr rv uozz zzou xcf fcx zm mz xnu unx sx xs ju uj ess sse sjvx xvjs ocvv vvco jvc cvj jtv vtj pobl lbop kgl lgk hf fh dxqh ...
output:
355466754
result:
ok single line: '355466754'
Test #15:
score: 0
Accepted
time: 0ms
memory: 11532kb
input:
40 15 occjsczezcsjcco odjqcujujucqjdo ckxmwkxxxkwmxkc cengyrspsrygnec mustbeqxqebtsum ojybscqgqcsbyjo jtdxwojojowxdtj jocjsdcecdsjcoj ugfdekcyckedfgu wstuseufuesutsw ygzvluajaulvzgy tbttlibvbilttbt curoimqsqmioruc zmnfwmdxdmwfnmz addnzxieixzndda mzhrceznzecrhzm viprlgbsbglrpiv agghkwooowkhgga waudmb...
output:
40
result:
ok single line: '40'
Test #16:
score: 0
Accepted
time: 410ms
memory: 17072kb
input:
181 1000 aecd dcea dgdg gdgd bg gb bea aeb aafd dfaa cegb bgec cbge egbc ggdd ddgg dbab babd eaca acae faf ef fe efea aefe feg gef eag gae cgd dgc fb bf egeb bege gcbf fbcg ffbc cbff fee eef cgg ggc dcd cbga agbc fa af fg gf badd ddab egf fge gffc cffg fdcg gcdf cdf fdc aceb beca dcgc cgcd aa becg g...
output:
550526203
result:
ok single line: '550526203'
Test #17:
score: 0
Accepted
time: 429ms
memory: 17452kb
input:
188 1000 gaac caag fb bf efad dafe fadg gdaf be eb bfd dfb fdfa afdf cdg gdc gfa afg agb bga fde edf faf ege fccc cccf bdd ddb ce ec gcd dcg gdgf fgdg bae eab ag ga db bd dfe efd aacd dcaa cgaf fagc dgcd dcgd agef fega dcd ge eg dgfd dfgd daaf faad acb bca cf fc fd df ea ae fdfg gfdf dfg gfd bg gb b...
output:
324658912
result:
ok single line: '324658912'
Test #18:
score: 0
Accepted
time: 372ms
memory: 16024kb
input:
158 999 iu cziz uyu clxkxlc s ll jjam kzonoz tydbdy g deffe c massam y cyc mvm xssx ege dhjdjhd d wcwix rr cjppjc icttci lzl rwrp vv dklhlkd uku f k sd u zkkxkkz r evjqjv q lpuplz kirgrik gj zqwq svzzvs kjjkc mu qvvq gtqtg mqmc p cvscsvc mymkz kkb v nd sxxs zxcxz l uppu ibnbi ynywyny ldtdl uzzu h ix...
output:
651380718
result:
ok single line: '651380718'
Test #19:
score: 0
Accepted
time: 329ms
memory: 15760kb
input:
152 999 kk d ww fbf qckakcq a p xxz jh ji kook npp fohof ddopod zddzr vkppkv fscsf rbrr hssh ezzev z addda smsw qq o rddr coc izz m n paffa syzzys toot q zzaazz eeh bkk wqqeqqw zfzc lcycycl vv j iccic nnfnni sfkkf u f yhqqh oyy rnxxnr c xennex ijpji kdk nno lxppx lyl v ucecu qzqp y cllc e eaeea ogmm...
output:
747844933
result:
ok single line: '747844933'
Test #20:
score: 0
Accepted
time: 356ms
memory: 15476kb
input:
146 999 fcbcfc f beeee ee ada cbce d dgagd dfd e ef bb ebbb a dd cdagadc c cagac fgfg fdfg dfefd eec aea dfddfd cg fccf bcegecb cbbce afefa affad cbgbcg adbda g b cc aaa ggbgg ff dbdbd bcbeb ffddff eddgdd ccbb bbf affa geeg egeg eaae ggfafgg fdedf efgegfe dcd abbag bbefeb eaddae eegee eee ebbec bbb ...
output:
282812880
result:
ok single line: '282812880'
Test #21:
score: 0
Accepted
time: 339ms
memory: 15312kb
input:
138 999 aecbcea c ceebeec afddfa b bbbc ff gb cc ceeee aa f d db dfd agaga cgc gcfafcg ggaagg a ecddce cefffec acbbca dfdfd fabaf baaab gcegecg eged fgbbg dcbbcd gbddb e dbdea beeb bdcdb g bbbb cbggbc fdaadf dbaabd gfgegfg bffffb bbdddbb adeda cf bcc ccccc ba dcde cbb bdb cdc fef cffc ce gbbbg geeg ...
output:
440062152
result:
ok single line: '440062152'
Test #22:
score: 0
Accepted
time: 314ms
memory: 16264kb
input:
157 1000 fttf pzp bpgrgpb r hch niin gng zrwwrz vqbbqv ghrvrh xrxf nkkn c m wz phhp jgaagj ufs jhhj uqqu bb d sdxlxd itti aa ihjojh q ma l dd fsksf cilicd s hmym z lorrol yya vgvv e frgrf gg runnur h lq f vavgf jqlqj kk jj pfzxzfp vv ff p w fzbbzf ylkzkly cddc dwaaw mi llxq ppp tgdgt rdidr oo g uxjt...
output:
763797775
result:
ok single line: '763797775'
Test #23:
score: 0
Accepted
time: 385ms
memory: 16076kb
input:
161 1000 ipvpi t a cbf n xqx g lmyyml mvm lww iki jsjn vvu okko waeea k ucnencu bb icwqwci xerexu qvvq z eqq q ooo qndn dmmmd hguugh tuut nww hii pr jjjj tncn zykk doodp yrwwry soqos ymy paa d zvwvwvz o yf gnhhng mmo v ee c yvuuvy i auhihu e qc wppw slobol eqxqe yuuy h wkckwp qv czbbzc dnmndq oc qfq...
output:
535630694
result:
ok single line: '535630694'
Test #24:
score: 0
Accepted
time: 359ms
memory: 15680kb
input:
148 1000 bababa eagga b ggaagg faaf bccb aggg d feff befe dfbfdd f deeee adcccda bebebe aa ea dfcfd g gaag dgaagd gddga ecgcea aaec dgggg ebcbe dabadc ge efcgcf dfdcdfd gga bg gdddg a gcfcg caaaac cagga eg edggde dcd ded cccc dadad gf egge dd fabba e edede c cgc dgfbfgd adda eacecae affa ff dbb ede ...
output:
966096873
result:
ok single line: '966096873'
Test #25:
score: 0
Accepted
time: 380ms
memory: 15752kb
input:
151 1000 fe aebeae ebdbe gfgfge aa eeceef cfeef cbbc cgbbg g ddffdd gbg dgdgd ce dd feef e gcg fgf ffc ded edde eaaed egg gga cgag aebb bffb aea faaf b a bdb dbbd c beeeb cg fddfe bfaaaf be faa ffggf agae d bd aac ggggga ggg deded cecce f adcd fbggbf gfg ged ec ddg ceec bgaagb adbbda cccc daa caddac...
output:
889599153
result:
ok single line: '889599153'
Test #26:
score: 0
Accepted
time: 0ms
memory: 11612kb
input:
40 15 nvjptihahitpjvn ylhltkisiktlhly hhgkxxayaxxkghh weiyqmgrgmqyiew idjkgseqesgkjdi svfbkelylekbfvs ojnyywsxswyynjo dlwvzhjljhzvwld nbqraeiaiearqbn nzeponsdsnopezn iegnwhjhwngeii tepagywswygapet iiyvgxhkhxgvyii vhvrepjpjpervhv wdtbjfqyqfjbtdw xjpzmgikigmzpjx ameyshumuhsyema wvrmmfobofmmrvw gknqomr...
output:
37
result:
ok single line: '37'
Test #27:
score: 0
Accepted
time: 0ms
memory: 11792kb
input:
50 45 uzxejdyfgkulynhvxycenuiunecyxvhnyluk gfydjexzu mwdd vou xxfu hfgwuc krozelezorkc uwgfhufxx uovddwm m lcyweunncuqshzfiwtrpmpmprtwifzhsqucnnuewyclm ckbzz iaazn ahksaebkxqrxexrq x k beaskhanzaaizzbkc vhxflf qrxlypdonwylboacocaoblywnodpylxrqflfxhv vfkylx snvkncftnop rxjzsmszjxrpontfcnkv nsxlyk fv ...
output:
805191073
result:
ok single line: '805191073'
Test #28:
score: 0
Accepted
time: 5ms
memory: 11852kb
input:
50 45 fzkqwmtntvuqjmpcaodqqzjzqqdoac pmjquvtntmwqkzf ywzd l wfswkvyozpgvchj voqovjhcvgpzoyvkwsf w ldzwy gwjuggqiqmbsvzaiyrpyanxnaypryiazvsbmqiqggujwg abrmsbvhzqox wruvcel dyx i xydlecvurwxoqzhvbsmrb a qlgxfachtgy k tp pymy smhcxchmsymypptky gthcafxglq psfulkvythpihwzqwloollplloolwq zwhipht yvkluf sp...
output:
645330232
result:
ok single line: '645330232'
Test #29:
score: 0
Accepted
time: 3ms
memory: 13540kb
input:
100 45 mkd eljh nlsjioclutgyn mdfdmnygt ulcoijsln hjled km u gfvbz q g fbsbua rrewylyoeoyly werraubsbfgqzb vfgu cavceh ejn qzm ygm qedawmfdfmwade qmgymz qn jehecva c rlrv uqzklocepkdcvsbeot wtoebsv cdk pecol k zquvrlr lmug lfqn vi chnwx ggke pjxixjpek ggxwnhcivnq f lg uml ehvzyqna qmezoeef hldhj fxf...
output:
198598295
result:
ok single line: '198598295'
Test #30:
score: 0
Accepted
time: 3ms
memory: 13476kb
input:
100 45 hwyoltqyq lnbx jmfmjr bmuvumbrjmfmjxb nlqyqtloywh i xt njv zrnugikk tdeyrd kw ewkdryedtk kigunrzvjntxi rl tpiyrxyv umxaindpf b lbbblbfpdni axm u vyxr yip t lr w sflbbb hyvfn vwkrrbcumtgtmucbrrk wvnfvyhbbblf sw nrmg oiwr lbmsefscwujvdejedvjuwcsfesmbl rwiogm rn ltrjdbkkuba axforrhwlblplblwhrrof...
output:
262104358
result:
ok single line: '262104358'
Test #31:
score: 0
Accepted
time: 8ms
memory: 14544kb
input:
120 45 ol vpyxugloemtludupxh mfnfmhx pudult meolgu xyp vlo wnfoub rtzby bqds xzndztziztzdn zxsdq by bztr b uofnw tbutr elu inlzyotynnxicjf jcixnn yto yz lniulert ubt sp wbosgt tnjtj ve ydkntuqcqutnkdy evjt jnttgsobwps v fppdp gwuv bbjiblm db gwxh xwgbdmlbijb bvuwgpd pp fv hyr vtpfi agxijv zgjgffkugu...
output:
973659104
result:
ok single line: '973659104'
Test #32:
score: 0
Accepted
time: 13ms
memory: 14348kb
input:
120 45 enttq c dh zcwkeadj ahy ulv dvluyhajdaekwczhdcqt tne lbafc ap ay ptjwdawnfkwspj pswkf n wadw jtpyap acfabl phokcguir uckxmfj ur z derkr e dz rujfm xkcuriugcko h p ziw ybbzggz zmba gstwpehggg hepwtsgabmz zgg zbb y wiz nw qwtkg j qjdnxcie jfugbjpjbg u fje i cxndj qjg k twqwn wxvxcz tn iw bij he...
output:
402382805
result:
ok single line: '402382805'
Test #33:
score: 0
Accepted
time: 0ms
memory: 11492kb
input:
50 45 ce gggagdgbab cccfg aggbbfbbggagfc ccbabg dgagg gec gaaa fggaeb gcacdfddg fbgagbfgd d fdcacgbeaggfaa a g fe dbce fcaddaecdeaagegbc bgegaaedceaddacfe cbdef gbfcfbd egbeaeffbbbaggdcdggabbbffe aebgedbfcfbg cceccdecbebedbdddgbcdfefdcbgdddbdebebc edcce cc gdfcbdbe cbgfcbecdafcggfggcfadcebcfgbcebdb ...
output:
706185447
result:
ok single line: '706185447'
Test #34:
score: 0
Accepted
time: 5ms
memory: 11816kb
input:
50 45 ccegffdgfab agadeggg fa edeafgggeda gabafgdffg ecc dagcgaceabg a bbdcegae bcccbeagecdbbagb aecagcgad efgdceffgbege bf befdgacbcagdfeb fbegebgffecdgfe cebfbgddbgcbbgffdgbgfcecfgbgdffgbbcgbddgbfbec fecfagfcf gcbfbaa ab afabcbafaba aabfbcgfcfgafcef fgeff ddfbbaabcbfdcfacdcdcafcdfbc baabbf ddffegf...
output:
305248114
result:
ok single line: '305248114'
Test #35:
score: 0
Accepted
time: 8ms
memory: 13612kb
input:
100 45 fdfac eeabfbgcdgbdb b abd fdbabbdb gdcgbfbaeec afdf aad db fffadfbgadfdagda eeeadgad fd agb fdafffbddaa baagb age ba fefdfdgfgedfcfdegfgdfdfefabegab gaab aabc dggfb acfc bebdafge gfgegf adbe bcfc abf ggdcbaa a ebecba ecbd bcgecga dffedeffd agcegcbdbceabcebea ageabdd acff ebafc cadgga fa ggd a...
output:
174507622
result:
ok single line: '174507622'
Test #36:
score: 0
Accepted
time: 9ms
memory: 13664kb
input:
100 45 abaedccgbceg eabccaac bfdfbcaacc bae ge c bgccde aba effgbgeafcggfbdb gegcfbgbfcge gbdbfggcfaegb gffe fb deac ddfbbfbadda eeb db gbdb eeaddabfbbf d dcaedbf ffbc faebaeebdda adg e fdbg bdfegd a add beeabeafcbf f bgeggbegfgfeadgbag ag bbebbgagabgdaef gf gebggegb eefdfedgcabgfacebdbdgd ddgdbdbec...
output:
666843253
result:
ok single line: '666843253'
Test #37:
score: 0
Accepted
time: 0ms
memory: 11252kb
input:
40 15 ljmpoadaopmjlo flqdsizxzisdqlf gflzbobkbobzlfg jzudxxpxxduzjp ljgwvedwdzynscb aipjiefzfeijpia hbstmixzlipivku zdhrdeeneedrhd kvbhkcjzjckhbvk qcuuliawgfvdjva bwsvcarfracvswb mtoudiiuiiduotm rngwkxlxkwgnr yyjokfafkojyy vnxdvncgcnvdxn hgghcsfschgghk gomenqlylqnemog hraxglguglgxarh aamaajefejaama ...
output:
15
result:
ok single line: '15'
Test #38:
score: 0
Accepted
time: 12ms
memory: 14652kb
input:
120 45 abd eaeecba d eecfb ecebfda dfbecebfc ee dabceea e db a bc gfcgcb ggbfaf cfggfc gbb b gcfg gfc fafbggbcgcfgcb gdf dfafcaa egecadbae dbg dgbdea bda c egeaacf afdfdg gb efebb gdbafcbg fdg cac fc fca cgdf gbcfab dgbbe feb g ba daecaag dcdfde ebfcgaa eaa gcfbee df dcdgaa ceadab edggbgbc dd eae ed...
output:
111550963
result:
ok single line: '111550963'
Test #39:
score: 0
Accepted
time: 16ms
memory: 14396kb
input:
120 45 gc cf gdb edcebddebgd c gbdedbgcdgbeddbe cdebd gfccg dfabe acdafed bdccbfafa babaf afb ccd bde fa d caebafd fgafaaecef agae a efdfg aafaagfdfeaeagafeceaafagf gab gd eef ac bgae bad dec egage ced da beagbcafeedgbag gffbefb dba cdgd dde fbaf cd cfab fe dddgd cabdb febffg b ecf fde dggc g bcfa e...
output:
965367719
result:
ok single line: '965367719'
Test #40:
score: 0
Accepted
time: 5ms
memory: 11700kb
input:
50 50 osa hmsc fkiiyzxj enip meillhhlliempinejxzyiikfcsmhaso xvosqxctdoabhkkxp ejpjffibbiffjpjepxkkhbaodtcxqsovx bbdjp mmwtjwoxxnkormzaxaottoaxazmroknxxowjtwmmpjdbb cimbnmggaqmqop ksduxqtzkqhhqkztqx udskpoqmqaggmnbmic ubrwzaxawvnjuhmphrvdg wjoyyoj wgd vrhpmhujnv wax azwrbu szcyfpbxysafpeqsoxpwipuiee...
output:
35139630
result:
ok single line: '35139630'
Test #41:
score: 0
Accepted
time: 5ms
memory: 11528kb
input:
50 50 xquvoqdecfnepfj uqpih bselkklesbhipqujfpenfcedqovuq x jlrsnhsf sfzupzdqgwkxjpoewweopjxkwgqdzpuzfsfsh nsrlj xlnynpe xltm zbs bzohtzeyhlb blhye zth ozbsbzmtlxepnynlx skzhsuosqkzfwfbkwl spsjnvbbvnjspsl wkbfwfzkqsoushzks cjekubbgasys fhcjrhruyjipggpijyurhrjch fsys agbbukejc g sgtuv ahcpxnsbudou vm...
output:
39334022
result:
ok single line: '39334022'
Test #42:
score: 0
Accepted
time: 6ms
memory: 13648kb
input:
100 50 qulvb yncjxclkcbylqq exfca k kac f xeqqlybck l cxjcn yb vl uq xjcpwgjnzffl stusttfpvtbqnnqbt vpfttsuts lff znj gwpc jx hav xaxirfddbjbfs awoshlojnn jolhs owasfb jb ddfrixaxvah ilvnaqjcgfxvlmndokvqh musq qsum h q vkodnmlvxfgcjq anv li hmtjnuyafixlsezp sdgspl vpllpv lpsgd spzeslxi fayun jtmh nw...
output:
725990680
result:
ok single line: '725990680'
Test #43:
score: 0
Accepted
time: 3ms
memory: 13584kb
input:
100 50 thxsurhfogodpf hhnga pi mapnnp amipagnhhfpd ogofhrusxht clekprbhbstyyl qv xzsc onhxvvxhno cszxvqlyytsbhbrp kelc xoipphi uk nbbkr sre x atxr vniinvrxtaxersrkb bn kuihppiox of mwqlv thwsr urhr jo juborfjjfrobujojrhru rsw htvlqwmfo murzbp milpcteppjgyzurjb appab jruz yg jppetcplimpbzrum tatldlit...
output:
85098510
result:
ok single line: '85098510'
Test #44:
score: 0
Accepted
time: 14ms
memory: 14480kb
input:
120 50 ybyftyzztcerkuqluqmzkuptnntpukzmqulqukrectzzyt fyby eg xo haslhllszeu z cg dvlia bxxbailvdgczu ezsll hlsahoxge eowkuehjifnuj cy apwa sp hlmq qm lhpsawpay cjunf ijh e ukwoe rre mtqz zxwoqykaqzenoxa ry gg yraxon ez q a k yq ow xz zqtmerr uneybihemefxblqqqbt qtsy eddeys tq t bqq qlbx femehibye n...
output:
579174037
result:
ok single line: '579174037'
Test #45:
score: 0
Accepted
time: 9ms
memory: 14800kb
input:
120 50 dx m wzzelhkyfqpgp q vfe vnjqddqjn vef vq pgp qfykhle z zwmx d xicptk tu nhhqq ecjexegycscxxcscyg ex ejceq qhhnutktpci x nbwzga gpozigkbylar i wu g fcjj cfguwiraly bkg izopga gz wb n lpflmu vn dghqhcvz ninphqrpffprqh pninz vchqhgdnvuml fp l qcn nfw akn mgcheeg qtrvbhs si isshbvrtqgee hcgmnkaw...
output:
26830905
result:
ok single line: '26830905'
Test #46:
score: 0
Accepted
time: 2ms
memory: 11636kb
input:
50 50 addgg dbfdfdgabdc fddgcgecddceg cgddf cdbagdfdfbdggdda afeaabafabcgdaagefag cfebee be f cgafegaadgcbafabaaefa fcgdefcagedaefcce cdd dddcbbcdddddce ccfeadegacfedgcf cccfebfffgcgeggeggeeecbcffcbceeeg geggegcgfffbefccc ededcabcbgffgf c ebfbddebaggabeddbfbecfgffgbcbacdede ee bgffbdgdafeabbdgbceedd...
output:
336364575
result:
ok single line: '336364575'
Test #47:
score: 0
Accepted
time: 0ms
memory: 11836kb
input:
50 50 gbadcc bcbdfdbbebdbgcedgbaabgdecgbdbebbdfdbcbccdabg agdbbggdebafccb egdbdbcgccccgcbd bdgebccfab edggb bdga bbfbeea ecfadebgfafgadbbfddfbbdagfafgbedafceaeebfbb ggeacfc ed dccceffbcfbfcadffdacfbfcbffecccddecfcaegg faaecfg cgbbbebfdagacbgfdeedfgb ca gadfbebbbgcgfceaaf cacedfdccgbbg febdf b fa dca...
output:
108988450
result:
ok single line: '108988450'
Test #48:
score: 0
Accepted
time: 0ms
memory: 11320kb
input:
40 15 bbaaaaabaaaaabb aaaaaabbbaaaaaa baaabaabaabaaab aaaaabbabbaaaaa abbbaaaaaaabbba bbabbaabaabbabb aabaabaaabaabaa baabaaaaaaabaab aababbbabbbabaa aabbaababaabbaa abaabbbbbbbaaba bbaababbbabaabb bbbabbbabbbabbb abaaaababaaaaba aababbaaabbabaa aaabaabbbaabaaa baaaabababaaaab babaabaaabaabab bbbbaa...
output:
40
result:
ok single line: '40'
Test #49:
score: 0
Accepted
time: 14ms
memory: 13684kb
input:
100 50 gbge edfc f e dbfg ae eaddacegaagecaddaeeag fb defcfdeegbg da gdebgde edeeaegagdbg dagff gadgb dg agea eed eedgbedgad fgdf caebcdgacbga ag cdffda ccadffdcga agbca gdcbea cf dgf bgf efbafc d ab afegb aaf gf baccabfgfaa b gefabadcfabf efgb gbbdb c bfcaabg aagddbdbgabbbbagbdbddgaag baacfbcbdbb g...
output:
111774342
result:
ok single line: '111774342'
Test #50:
score: 0
Accepted
time: 7ms
memory: 13720kb
input:
100 50 agdd fefgd baa caeeggfeage fbb fe ga ef ggeeacaabdgf efddga cddgade bffcfbafabgdgbaaef f eaabgdgbafabfcff be dagd dc dca faceeebfgdeabdg gfgaedd ddeagfggdbae dgfbeeec afa c d gacbebgdd bcebaaddg eb ebdbggbdbe begddaabecbddgbe bcag dd dccaggdbbda bcf bfaf fegeaaege ffafbfcbadbbdggac cddd aac e...
output:
71957286
result:
ok single line: '71957286'
Test #51:
score: 0
Accepted
time: 18ms
memory: 14480kb
input:
120 50 faceaead eeg daecc bf fgag baggab gag ffbcceadgeeda eaecaf e eead gbegeg edg dc bea ea ebfc cf beaea ebcdgde gegebgd aeee g dadgebedc fe gggbd baegdcbc cbcdg eabd bgggefcd ebegdadg ffedbc gfcea cgfgedfecceee a ae ee cce fde gfgca ecf gcb deff dfffab cggaabef cd aaga dcca eeacc dagaadcfeb aagg...
output:
182654829
result:
ok single line: '182654829'
Test #52:
score: 0
Accepted
time: 13ms
memory: 14624kb
input:
120 50 geca gb d c eaf eabe bfe ccg feb ggbe fg ccefb eba efaecdbgaceg baceaddf db ccd acadgcabegbffbg eb acg dac adcc bdfdda ecab bcc ae cbdf acc ee ggcfgfeeacf f caeefg fc ggeeccaf dbce ac cb fdfdgedf bdd cg aeab gcca g bdggdb gaccgbaeagcddbfdegd fdf fgfccaf a efc defc bcbdaecbfgg fbcea dbcbcfe dc...
output:
338521041
result:
ok single line: '338521041'
Test #53:
score: 0
Accepted
time: 22ms
memory: 11572kb
input:
50 999 wmqvvinuzmakpepkamzun ivvqmw mbaarbyhjkcnhthnckjh ybraabm aepnver srsnaxbxa nsrsrevnp e a kfzkimxqxydujsjudyxqxmikzfk osrefuigeqzrjo jrzqegiuferso tbdlgdh lvrskhm hksrv lhdgldbt isl xuwtihjmbvkvbmjhitwuxlsi bfphvsmyks axvlvxaskymsvhpfb ztvcsdugoylgaaaglyogud sc vtz w uzircqsco tvglgvtocsqcriz...
output:
440739609
result:
ok single line: '440739609'
Test #54:
score: 0
Accepted
time: 28ms
memory: 11672kb
input:
50 999 vlqhevvcnyjfphpfjyncvvehql v xcfhppjaciuznsnzuic ajpphfcx bwaioxeigjvbeqebvjgie xo iawb uojgpq zfffwcvuvcwfffzqpgjou umkyefruqxbdwmwdbxqurfeykmu fpdsashcijhlkqklhjichs asdp f zodap eblkdgvirivgdklbepa doz em pr mnpteqhterethqetpnmrpm e gxzsinplcvqwukuwqv clpniszxg yxrsiruehtwzpgpzwtheu risrxy...
output:
240351931
result:
ok single line: '240351931'
Test #55:
score: 0
Accepted
time: 118ms
memory: 13628kb
input:
100 999 uwxipe m cqk amsosmakqcme pix wu ohf tlcasrbgren ergbrsac ltfho ojjabwyqoydryfyr dy oqywbajjo owsr boyuzdwvw jwvwd zu yobrswo gwrhbrmxs wrzkpkzrws x mrbhrwg nk mmafyoi r n adhdan rioyfamm kn d hwculzkoymqxax q myokzlu c whd fjtdeiexi oqplp l pqoixeiedtjf i vk ocltbnld uo joudlnbt lcok vi bub...
output:
394342113
result:
ok single line: '394342113'
Test #56:
score: 0
Accepted
time: 127ms
memory: 13804kb
input:
100 999 jjlwnaqsksohdodhosk sqanwlj j bufuux syjk xwu buwxkjysxuu fub zkwyzv h nejvviwivv jenh vz ywkz blaqavcv qpr aenearpqv cvaqalb xygwlyhyouds ososduoyhylwgyx bsxcvl bel iicv a vciilebl vcxsb spvctow ck qmqrzr qmqkc w otcvp s t zgki u mgy spblr lbp sygmuikgzt qhve mcqdqthkylykhtqdq cmevhq mcikct...
output:
934790014
result:
ok single line: '934790014'
Test #57:
score: 0
Accepted
time: 167ms
memory: 14500kb
input:
120 999 qddz fgla xqbuol oub qxalgf zddq nmza r e sf xpkdsf sdkpxfse razmn yf x xshp umf nqr arqn fmuphsxxf y bz bixbqwty q ypxp yqytwq bx i bzb uc p lhmvo kjgmqgq mg jkovmhlpcu lboq dmzqt sy npb pn ystqzmd qobl c a kkcy syc ibqk dkqbicys yc kkac ha orslxdgxadsu sdaxgd xlsroah mvtf osf aqneydvd yenq...
output:
718373891
result:
ok single line: '718373891'
Test #58:
score: 0
Accepted
time: 170ms
memory: 14616kb
input:
120 999 r swwoiztkpewbabwepktzioww sr pm mu tv qnuh fvxixvf hun qv tummp hdrhxfaxjsxeo zoe xsj xa fx hr dh hc e ixtianzxlcqclxznaitxie ch cjjct vgkahifada fihak g vtcj j c swob ukydislhcechlsidyk ubows pvgksylvi hbx ioi xbhi vlyskgvp t q cclfyvb bqgwi wgqbbvy flcc qt jvoa tfjvxaagg o ggaaxvjfta ovj ...
output:
782458717
result:
ok single line: '782458717'
Test #59:
score: 0
Accepted
time: 4ms
memory: 11592kb
input:
40 15 ababaaaaaaababa aaaabaaaaabaaaa baababaaababaab abaabbababbaaba abaabaaaaabaaba bbaabbaaabbaabb aababababababaa bababaaaaababab aabbaaabaaabba aabbbbaaabbbbaa bbaaabaaabaaabb aabbbaaaaabbbaa aabbaabbbaabbaa baabababababaab bbbbbabaaaaabaa bbabaabbbaababb bbbaaabbbaaabbb baabaababaabaab aabaabb...
output:
35
result:
ok single line: '35'
Test #60:
score: 0
Accepted
time: 38ms
memory: 11668kb
input:
50 999 afggdcegdacc gfgccadgecdggfa bafgcgddgccfbbbfccgddgcgfab efdbfbff egfbf afbfgeffbfbdfe gdagbbeabbdcafacdbbaebbgadg bgbgc ggggcbb bbbbbcggggcgbgb ffaffcaebcfgdgdgfcbeacffaff dgbbgcdaccaga bagac cadcgbbgd ecfgdgdebcdgcbcgdcbedgdgfce gggbbcdg dbdcegecdbdgdcbbggg agbbbdcfdbafafafabdfcdbbbga bf eg...
output:
60641896
result:
ok single line: '60641896'
Test #61:
score: 0
Accepted
time: 30ms
memory: 11896kb
input:
50 999 ebcbagggfgbgfffgb gfgggabcbe geagfcgfcgbbdddbbgcfgcfgaeg gcfffefgegbfgegfbgegfefffcg dbfa fbcbecbdfdfdbcebcbfafbd gbcbee dbccbaabaabccbdeeb cbg dbdffbgdef fefdfeffedgbf fdbd fbbafabaacdbgcgbd ca abafabbf bdegcgaeefegcfcgefe eagcgedb aaabfbeeebaafcfaabeeebfbaaa ffcfebfbbadbfcfbdabbfbefcff fd g...
output:
265212824
result:
ok single line: '265212824'
Test #62:
score: 0
Accepted
time: 243ms
memory: 13612kb
input:
100 999 adaaef bfbagcf gfcga bfbfeaada dgeddbgffg fb bebbfgffgbddegd aeeg fdgafafe egeefafagdf geea gadd afdda bgaeb ea gbaddfa d dag adbfbce ffgagefeg a gffecbfbda f ca daaggbaagfgf gaabggaadacf adcd debged ggc ccg gdegbeddcda fdeeebg bbdabfafba dbbg beeedf dbaaddffgcga gfga gc gffddaabd dfdf geg d...
output:
889332053
result:
ok single line: '889332053'
Test #63:
score: 0
Accepted
time: 244ms
memory: 13684kb
input:
100 999 d gd adcbcegcfaeafcg e cb cd adgd egaabffae ccae beacceaffbaage bgd cdbbf fb b deaedbbf fbbdcdgb ac becce ec eefd edfeecee cce bca bad ggecgccf eag aefcc gc egg dab c cad edbfgdebadabedgfbdedacc bge efcfgbf ebeeeb efbgf cfeegb ad edeg fecg eafbfaegcefg eded a dadaafege ab ecf cebaegef aa dad...
output:
975777964
result:
ok single line: '975777964'
Test #64:
score: 0
Accepted
time: 300ms
memory: 14748kb
input:
120 999 bda g badcdea ccecca ed c dabgadb de e debcgbddg d ddgddb gcb edeed ce dfacbc eafb bebbfae cbcafdec cfebddddaccae eeaccaddddb efc bccedadefce egdgeecfed adec cb dfd a baacefbgdgdgbf ec aabadfd fef ccgegadd bed ebdd ag eg ccfef cebadgbbg agda dadgagbbgd abec afdag gcac gbfedefb gca cggadfa bc...
output:
140229783
result:
ok single line: '140229783'
Test #65:
score: 0
Accepted
time: 295ms
memory: 14564kb
input:
120 999 egedce ffag fd bcbdf gaff ecdege ddgd bcfecbeb dg dbebcefcbd g dd cac eab aebce agbga e cbeab aecac cdcffaa gdfd abebadfdgaaffcd c cddcadddcafbefe bfac d ddacddc a bbbfge afdcfbf bfcdf aegfb bba fgf dccbgebbfgegfbb egb ccdfgf facdad cfegfda eadf gefcda dcaf cbdac gf af fgbdbd b gffa fgcadbc ...
output:
462472220
result:
ok single line: '462472220'
Test #66:
score: 0
Accepted
time: 15ms
memory: 11608kb
input:
50 1000 jokdoo dsteets doodkoj fytqqsqxxhhxxqsqqtyf nphjsjkxattaxkjsjhpn uxo qbzcvnnnnvczbqoxu htjyejswviivwsjeyjth gbensdzhkrrkhzdsnebg yudadvexjxxjxevdaduy pgpraqusejjesuqarp gp crfvpkxpkttkpxkpvfrc yxgmdqlp wqq wplqdmgxy cvtsdzlnjttjnlz dstvc mubssxlltuutllxs sbum cttdkdstzcczt sdkd ttc piy evokc...
output:
592531190
result:
ok single line: '592531190'
Test #67:
score: 0
Accepted
time: 15ms
memory: 11608kb
input:
50 1000 ieqbtm jtkkkktjmtbqei cywkzohtvssvthozkwyc tnjjnx yuco ocuyxnjjnt dnjc kzisccccsizkcjnd hsagfjvt mhhmtvjfgash jvdhvaqqlkklqqavhdvj xzcvxolxttttxloxvczx ibzcwgasqllqsag wczbi niqfeamddooddmaefqin gbonqydnaggandyqnobg wmuzfkfkzrrzkfkfzumw g ljrkcsmcqqcmsckrjlg nmidtzrqgmmgqrztdimn omd lbxwfctt...
output:
869827957
result:
ok single line: '869827957'
Test #68:
score: 0
Accepted
time: 104ms
memory: 13876kb
input:
100 1000 hhmexseh fssfhesxemhh lb th ksqvqwwq vqskhtbl xeldiwqufaafuqwidl ex cdqqffmhujju hmf fqqdc cwinzzyscbbcsyzzniw c dj zjkd hlntt nlhdkj zjd y f fch jsnjhhjnsjhcffy erupx qegm hhmgeqxpure hex szx ayff ff yaxz sxeh xm axdil huz zuhlidxamx rbitxudo tjjtoduxtib r rrtdh brixrrxirbhdtrr bpmz tousdv...
output:
240955559
result:
ok single line: '240955559'
Test #69:
score: 0
Accepted
time: 107ms
memory: 13648kb
input:
100 1000 axg tafjwicciwjfa t gxa uwceaatufxxfu ta aecw u xitoooiunzznui oootix udi yyppnnoon n ppyy idu p fxo jn pctjjtcpnjoxfp olncifuuzoozuufic nlo awem dvr tfzzftrvdmew a i gq wujw uouuou wju wqgi ivcvc nsdf ssf dsncvcvi makxsxbwdxxdw bxsxkam sshhgh vgnkkngv hghh ss mnjn lc ut qeeqtu cln jnm lcpw...
output:
60110416
result:
ok single line: '60110416'
Test #70:
score: 0
Accepted
time: 0ms
memory: 11236kb
input:
40 15 babaaabbbaaaba aababaaababaa bbbaaabaaabbb abbabaabaababb aaaaabaaabaaaa abbaaaaaaabba aabaabbbaabaab aabbbaaabbbaab bbaaabbbaaabb abaaabbabbaaaba ababababababab baaaabaaaaaabab bbbabbabbabbba bababbabbababb babbaababaabbab aaabababababaa bbbaaaaabbbbaaa bbbabbbbbbbabb abaabbabbaaba aaaabbbbba...
output:
11
result:
ok single line: '11'
Test #71:
score: 0
Accepted
time: 173ms
memory: 14376kb
input:
120 1000 ewigf yykpd d pkyy fgiwe thfk cw jppkkppjwckfht qej osdqtfbb ftqdsoje q mbk dhlchiuuihclhdkbm wxkwtbtxjbb jxtb twkx w avc vl ptqiyyiq tplvcva fdxbncksty ytskc nbxdf mj c jism touu otms ijcjm v tih syvx hxxh xvy shitv hpevphrhzyyz hrhpveph ouwsia i xerrexiaiswuo abztsy lrummurlystzba bxg daj...
output:
763293821
result:
ok single line: '763293821'
Test #72:
score: 0
Accepted
time: 193ms
memory: 14456kb
input:
120 1000 wct vrng mqzzqmgnrvtcw u c ur lrvyh ddhyvr lrucu gvlkcc akthhtka ccklvg ibrpswpmgcc gmpwsprbi cuay s toij ttj iots yauc guuo ihut ig git uhio uug ydesofeonjjnoefos edy npvgykzt owwot zkygvpn xkcrai suc eecusiarckx b esenmqdtxxtdqmn eseb jrddd gvxpddpxvg dddrj rtra rk lw ku ukwlk rartr hltpg...
output:
495766756
result:
ok single line: '495766756'
Test #73:
score: 0
Accepted
time: 37ms
memory: 11592kb
input:
50 1000 fdbbdaadffffdaadbbdf gaagedebeeeebedegaag dbfeabaegdd g eabaefbd cgfbbgeeaccaeegbbfgc eabdb gedffffdegbdbae bdg cfccbbddbbccfcgdb fc cfefc feggefcfefccf febfdbagfaafgabdfbef dfceagfbaccabfgaecfd cdbceeadecce daeecbdc ggddabe daddadeba ddgg gacegdgedeedegdgecag gaebddaddggddaddbeag cfeaeaggab...
output:
154566828
result:
ok single line: '154566828'
Test #74:
score: 0
Accepted
time: 32ms
memory: 11780kb
input:
50 1000 ggfcefbebccbebfecfgg babbgabgfddfgbagbbab egfcdacefccfecadcfge dfbagedfbcc bfdegabfd dgbgge aecdd c eaegg bgd daacdgfgaffagfgdcaad ega bbbgedbbdegbbba ge feaaegdddccdd dgeaaef dgcaegaafggfaageacgd eedaggfefeefefggadee dafgggcgccccgcgggfad bdeeebcgebbegcbeeedb fadceagebffbegaecdaf caace dabfc...
output:
349931605
result:
ok single line: '349931605'
Test #75:
score: 0
Accepted
time: 247ms
memory: 13788kb
input:
100 1000 a cbegbaaeggeaabg e bca bcaeb ge eaeeaeegbeacb fagadfafabbafafdag af fcagfbdffdd ffdb f gacf fg bg eabec ccc ebaegb gf ag debbgccggccgbbedga aegf fbfd aaaa df bff gea b bgbcabggaaggbacbgbb dcaedab adbbdabadeacd cdbabc dgaddagdcbabd c cgdd dfe bbaa bbefdd dgc fceaecdabbbb ad ceaecf bcddd aad...
output:
269597200
result:
ok single line: '269597200'
Test #76:
score: 0
Accepted
time: 212ms
memory: 13764kb
input:
100 1000 fffadcdegeegedcdafff gfecgfccba abccfgcefg e fcbb cgcdeedcgcbbcfe ccgbfegbbaabbgefbgcc cc fbbcfedccdefcbbfcc fdfbfd afge egf adf bfdf bdcafaedgdd gdeaf a cdb gd dgdgbagffga bgd gdd g gcfbcd gf fddff gdcbfcg dbaadaedecc edeada abd acfbd gecg gggceg dbfca dddef fcafaa facffeddd dgbfddbac ggca...
output:
36498743
result:
ok single line: '36498743'
Test #77:
score: 0
Accepted
time: 299ms
memory: 14636kb
input:
120 1000 ebddf acdgccgdcafddb e gcgdegcade ed acgedgc g edbfeabbga agbbaefbde acbg dgfgeaae gfgdgbca dgbbeecdfggfdc ee b bgd afdbd c gfffff fg cdbdf a cb bfd fbc fccfc bfdfb bc ddcffabfggggfbaffcdd egbgfagbcbbcbg afgbge ecbcecec gaa gc ec ecbce egc ff edgbaab gdeffc ge f gbdffdba bbab dffdbgf de da ...
output:
511078806
result:
ok single line: '511078806'
Test #78:
score: 0
Accepted
time: 301ms
memory: 14708kb
input:
120 1000 bf gc gfaac b bcaafgcgfb dac afdbaggggabdf acad cadff ggd baa bdg gffdac ddcafbbe a ccaebbfacdd cfc agg cfcffcfcggacfc cccedgge edde eg gdeccc aeecffdfge egfdffceea eda gdbeg cffcgebdga de adbeeaea cb bcaeaeebda edbf bceebc cbeecb fbd e fddgbbb dfaafd bbbg dd f gefdbfcgfaafgc fbdfeg bdfcbgg...
output:
497226421
result:
ok single line: '497226421'
Test #79:
score: 0
Accepted
time: 296ms
memory: 13060kb
input:
84 999 a b aaaaaaaaaaa baaaaaaaaaaa abaa aaaaaaa aab aabaa abba abaaaaaaaaba baba aa aabaaaa ba abaaaaaaa aaaa aaaaaaaaaaaa aaabaaaaaaa ab aaaba aaaaaaaa baa aaaaabaaaaaa aba babaaaa aaaaaaaabaaa aaa aaaaaba aaaaa aaaaaab aaaaaa abaaaaaaaaaa aaaab aaaaabaaaaa aaabaaaa aabaaaaa baaaa aabaaaaaaaaa aaa...
output:
49811881
result:
ok single line: '49811881'
Test #80:
score: 0
Accepted
time: 281ms
memory: 13180kb
input:
83 999 a b aa baaaaa ab aaaabaaaa baaaaaaab aaaaaaabaa ba aaaaaaa aaaaaaaaabaa aaaaabaaba aaaaa aaaaaaaaaa bb baaaaabaaaab aaa aba aaaaaaaaba aaaaaabaaa aaaa aaabaa aaaaaaaa aabbaaaa baba aaabaaa aaabbaaa aaaaaaaaaaaa aabaaaaa aaaaaba aab aaaabaaaaa aaab abaaaaa aaaba aaaabaaa aabba abaaabaaaa aaaaa...
output:
430092403
result:
ok single line: '430092403'
Test #81:
score: 0
Accepted
time: 4ms
memory: 11192kb
input:
33 18 dgqxnkajnnjaknxqgd htcuxrurzzrurxucth eqpadrufzzfurdapqe dckewyvsvvsvywekcd tmqycoxgiigxocyqmt rdtuysmhcchmsyutdr lveegcopjjpocgeevl mbzagzmuddumzgazbm rfutprcwwwwcrptufr gjyegdxuffuxdgeyjg hvkfsvqorroqvsfkvh xjeverkwttwkrevejx knvvrggsyysggrvvnk kxanwcuxccxucwnaxk nlsdwinjttjniwdsln fygjzucfg...
output:
33
result:
ok single line: '33'
Test #82:
score: 0
Accepted
time: 246ms
memory: 12912kb
input:
76 999 a b aaaa aaaaaaaa aaaabaaaaa aaaaaaba aaabaaaaaa aaaabaaa aaaaaaaaaaaa aaaaaaaabaaa aaabaaaaa aaaaabaaaaaa aaba aaaaaaaaa baaaaaa aaaaaaa aaaaaaaaaa aaaaa aabb bbbaa aaaaaaaaaaa aaaaababaaaa aaaabaa aabaaaaaa aaaaab aaaaaabaa aaaaaabaaba aaabaaa baaaaaaaa abaa aaaab aabaab aabbaaaab aaaaaaaaa...
output:
595711276
result:
ok single line: '595711276'
Test #83:
score: 0
Accepted
time: 248ms
memory: 12988kb
input:
78 999 a b aaaaaaaaaa aaaaaaa baaaaaa aaaba aaaaaaaaaaaa aaaa aaaaa aaaaaaaaaaa bbaa abbaa bbabb abaaa aaaaabaaaaaa aaaaaaaa aaaaaa aaaaaaaabaa abaaaaa aaaaaaaaab aaaaaaaaabaa baaaaaaa aaaaaba bbaaaab aabba aabaaaaaaa abaaaa baaa aaab aaaaba aaaaabaaaaa baaaa aaabaaaa baaaaaaaaaa baaabaaaaaa abaa bb...
output:
558891114
result:
ok single line: '558891114'
Test #84:
score: 0
Accepted
time: 286ms
memory: 13120kb
input:
80 1000 a b aaaaaaa aaaaaaaaaaaa aaabaaaaaaaa abaabaaaa aaba aaaaaaaa aaabaaaa aaabaaaaaaa aaaaba abaaaaa aabaaa aaaaaa aaaab aa aaaaaaaaa aaaabaa aaaaaaaaaaa aaaa aabaa ababaa baaaaa bb abbaa abba aaa abaa aaabaaaba aaaaaaaaab ab aaaaaaaaba abaaaaaaa abaaa aba aaaaa aabaaaaaaaaa baaaba abaabaa aaaa...
output:
439621743
result:
ok single line: '439621743'
Test #85:
score: 0
Accepted
time: 294ms
memory: 12924kb
input:
83 1000 a b abaaaaaaaa aaaabaaaaaa abaa aaaaaaaaba baaaa aa aba aaba aaaaaaab aaaaaaaaaaa aaaa ab aaaaa aaaaaaa aaaaaaaabaa aaaaaaaaaaaa abaaa aaaaaaaab babab bb aaaaaaaaaa aaaaaaabaaa baabbbb aaaaaaabaaba baabaaaaa baaa aaaaaa aaaaaaaaa aab babaaaa baaaaaaaaa aabaaaaaaaaa aaab aaabaaaaaaa aaaaaaaa ...
output:
818953340
result:
ok single line: '818953340'
Test #86:
score: 0
Accepted
time: 246ms
memory: 12524kb
input:
74 1000 a b aaaaaa aaaaaabaaaaa aaaa aaaaaaaaba baaa aaaaaaa abaaaa baaaaaa aaaaaaaaaaa aaaaaaaaa baaaa abaaaaba aaba aaaaba aaaaabbaaaa aabaaaaaaaaa aaabaa aaabaaa aaaaa aabaa aaaaaaaaaaab aaaabaaaa aaaaaaaa aaaaaabab aaaaaaaaaaaa ababaaaa aaaaaaabaaaa abaaaaaaaaaa aabaaaaaa aaabaaaaaaaa aaaaaba aa...
output:
288388585
result:
ok single line: '288388585'
Test #87:
score: 0
Accepted
time: 241ms
memory: 12936kb
input:
76 1000 a b aaaaaaaaaaaa baaaab aabbaaaaa aaaaaaaa aaaaa aaaaaa aaaaaabaaaaa abaaaaaaa aaaaabaa aaaaba aabaaaaa aaaaaaaaa aaabaaaaaaa aaaababba aaaaaaaaaaa aaaa aabaaaaaa abaaaaaaaaaa aaaaaaaaaab baaaaaaaa aaaaaaa aaaaaaba aaabaaab aaaaaaaaaa baaaaaa aaaaaaabaa baaaaaaaaaaa aaaaaaaab aaaba aabaaaaab...
output:
389885968
result:
ok single line: '389885968'
Test #88:
score: 0
Accepted
time: 4ms
memory: 11148kb
input:
33 18 wanmnojveevjonmnaw kwdqtxehyyhextqdwk sjpdfjzqqqqzjfdpjs heoyvoveddevovyoeh goxygrsbmmbsrgyxog prkgvkwvzzvwkvgkrp woxnamfkddkfmanxow dpwxepmwwwwmpexwpd ueqgrbkyykbrgqeuf ufkfiarhoohraifkfu vregvkugeegukvgerv vkvulsnxrrxnsluvkv wreonqmwhhwmqnoerw yrqzybjaooajbyzqry fzoupfcgiigcfpuozf vibyzxridd...
output:
30
result:
ok single line: '30'