QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353027 | #7994. 勿蹖宠物 | Kevin5307 | AC ✓ | 732ms | 6836kb | C++20 | 1.8kb | 2024-03-13 19:51:52 | 2024-03-13 19:51:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
string s[404];
map<char,int> tr1[606],tr2[606];
string ind1[606],ind2[606];
int tot1=1,tot2=1;
bool nd1[606],nd2[606];
int dp[606][606];
void upd(int &a,int b)
{
a+=b;
if(a>=mod)
a-=mod;
}
set<string> st;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,l;
cin>>n>>l;
for(int i=1;i<=n;i++)
{
cin>>s[i];
st.insert(s[i]);
int cur=1;
string tmp;
for(auto ch:s[i])
{
tmp+=ch;
if(!tr1[cur].count(ch))
{
tr1[cur][ch]=++tot1;
ind1[tot1]=tmp;
}
cur=tr1[cur][ch];
}
tmp.clear();
nd1[cur]=1;
cur=1;
reverse(s[i].begin(),s[i].end());
for(auto ch:s[i])
{
tmp+=ch;
if(!tr2[cur].count(ch))
{
tr2[cur][ch]=++tot2;
ind2[tot2]=tmp;
}
cur=tr2[cur][ch];
}
nd2[cur]=1;
}
dp[1][1]=1;
for(int i=1;i<=l/2;i++)
{
static int ndp[606][606];
memset(ndp,0,sizeof(ndp));
for(int a=1;a<=tot1;a++)
for(int b=1;b<=tot2;b++)
if(dp[a][b])
for(auto pr:tr1[a])
if(tr2[b].count(pr.first))
upd(ndp[pr.second][tr2[b][pr.first]],dp[a][b]);
for(int a=1;a<=tot1;a++)
for(int b=1;b<=tot2;b++)
dp[a][b]=ndp[a][b];
for(int a=1;a<=tot1;a++)
for(int b=1;b<=tot2;b++)
{
if(nd1[a])
upd(dp[1][b],ndp[a][b]);
if(nd2[b])
upd(dp[a][1],ndp[a][b]);
if(nd1[a]&&nd2[b])
upd(dp[1][1],ndp[a][b]);
}
}
st.insert("");
int ans=0;
for(int a=1;a<=tot1;a++)
for(int b=1;b<=tot2;b++)
{
string s1=ind1[a],s2=ind2[b];
reverse(s2.begin(),s2.end());
if(l%2==0)
{
if(st.count(s1+s2)) if(((a>1)^(b>1))==0)
upd(ans,dp[a][b]);
}
else
{
for(char ch='a';ch<='z';ch++)
if(st.count(s1+ch+s2))
upd(ans,dp[a][b]);
}
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5108kb
input:
7 9 cats eel eve evil lee olive stack
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5116kb
input:
2 2 a aa
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5188kb
input:
6 12 aa aab no on pets step
output:
43
result:
ok single line: '43'
Test #4:
score: 0
Accepted
time: 21ms
memory: 5224kb
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: 25ms
memory: 6520kb
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: 17ms
memory: 6504kb
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: 15ms
memory: 6532kb
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: 14ms
memory: 6252kb
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: 522ms
memory: 6140kb
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: 540ms
memory: 6136kb
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: 260ms
memory: 5832kb
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: 242ms
memory: 5716kb
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: 214ms
memory: 6404kb
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: 218ms
memory: 6364kb
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: 510ms
memory: 6836kb
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: 135ms
memory: 5732kb
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: 133ms
memory: 6068kb
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: 644ms
memory: 6276kb
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: 650ms
memory: 6204kb
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: 403ms
memory: 6028kb
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: 411ms
memory: 6272kb
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: 248ms
memory: 6476kb
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: 255ms
memory: 6392kb
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: 167ms
memory: 6200kb
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: 173ms
memory: 5972kb
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: 488ms
memory: 6824kb
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: 482ms
memory: 6508kb
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: 493ms
memory: 6804kb
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: 446ms
memory: 6352kb
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: 474ms
memory: 6664kb
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: 427ms
memory: 6356kb
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: 420ms
memory: 6580kb
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: 448ms
memory: 6476kb
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: 453ms
memory: 6420kb
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: 323ms
memory: 6224kb
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: 343ms
memory: 6200kb
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: 458ms
memory: 6468kb
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: 289ms
memory: 6132kb
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: 292ms
memory: 6104kb
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: 29ms
memory: 6536kb
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: 32ms
memory: 6536kb
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: 31ms
memory: 6460kb
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: 30ms
memory: 6484kb
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: 26ms
memory: 6352kb
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: 29ms
memory: 6400kb
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: 29ms
memory: 6480kb
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: 33ms
memory: 6440kb
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: 267ms
memory: 6260kb
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: 25ms
memory: 6224kb
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: 24ms
memory: 6268kb
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: 22ms
memory: 6128kb
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: 21ms
memory: 6352kb
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: 732ms
memory: 6804kb
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: 718ms
memory: 6592kb
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: 677ms
memory: 6672kb
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: 685ms
memory: 6372kb
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: 647ms
memory: 6372kb
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: 666ms
memory: 6588kb
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: 269ms
memory: 6260kb
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: 645ms
memory: 6716kb
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: 678ms
memory: 6440kb
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: 541ms
memory: 6268kb
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: 542ms
memory: 6148kb
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: 476ms
memory: 6076kb
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: 478ms
memory: 6068kb
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: 243ms
memory: 6452kb
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: 250ms
memory: 6532kb
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: 241ms
memory: 6612kb
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: 256ms
memory: 6376kb
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: 211ms
memory: 6304kb
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: 253ms
memory: 6440kb
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: 255ms
memory: 6572kb
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: 229ms
memory: 6416kb
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: 230ms
memory: 6460kb
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: 213ms
memory: 6264kb
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: 207ms
memory: 6236kb
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: 187ms
memory: 6332kb
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: 194ms
memory: 6384kb
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: 73ms
memory: 5496kb
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: 69ms
memory: 5488kb
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: 24ms
memory: 6764kb
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: 69ms
memory: 5460kb
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: 76ms
memory: 5480kb
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: 40ms
memory: 5432kb
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: 49ms
memory: 5472kb
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: 47ms
memory: 5628kb
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: 45ms
memory: 5656kb
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: 24ms
memory: 6540kb
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'