QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296936 | #7994. 勿蹖宠物 | Heltion# | AC ✓ | 437ms | 24160kb | C++20 | 3.5kb | 2024-01-03 20:01:04 | 2024-01-03 20:01:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...) 417
#endif
using i64 = int64_t;
constexpr i64 mod = 1000000007;
void add(i64& x, i64 y) {
if ((x += y) >= mod) { x -= mod; }
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(20);
int n, l;
cin >> n >> l;
vector<string> s(n);
string ss;
vector<int> begin(n);
for (int i = 0; i < n; i += 1) {
cin >> s[i];
begin[i] = ss.size();
ss += s[i];
}
debug(s);
int m = ss.size();
vector<int> id(m, -1);
for (int i = 0; i < n; i += 1) { id[begin[i]] = i; }
for (int j = 0; j < m; j += 1) {
if (id[j] == -1) { id[j] = id[j - 1]; }
}
vector<vector<int>> p((m + 1) * (m + 1));
for (int i = 0; i <= m; i += 1) {
for (int j = 0; j <= m; j += 1) {
if (i == m and j == m) {
for (int si = 0; si < n; si += 1) {
for (int sj = 0; sj < n; sj += 1) {
if (s[si][0] == s[sj].back()) {
int x = s[si].size() == 1 ? m : begin[si];
int y = s[sj].size() == 1 ? m : begin[sj] + ssize(s[sj]) - 1;
p[i * (m + 1) + j].push_back(x * (m + 1) + y);
}
}
}
continue;
}
if (i == m) {
int sj = id[j];
for (int si = 0; si < n; si += 1) {
if (s[si][0] == s[sj][j - begin[sj] - 1]) {
int x = s[si].size() == 1 ? m : begin[si];
int y = j - begin[sj] - 1 == 0 ? m : j - 1;
p[i * (m + 1) + j].push_back(x * (m + 1) + y);
}
}
continue;
}
if (j == m) {
int si = id[i];
for (int sj = 0; sj < n; sj += 1) {
if (s[si][i - begin[si] + 1] == s[sj].back()) {
int x = i - begin[si] + 1 == ssize(s[si]) - 1 ? m : i + 1;
int y = s[sj].size() == 1 ? m : begin[sj] + ssize(s[sj]) - 1;
p[i * (m + 1) + j].push_back(x * (m + 1) + y);
}
}
continue;
}
int si = id[i];
int sj = id[j];
if (s[si][i - begin[si] + 1] == s[sj][j - begin[sj] - 1]) {
int x = i - begin[si] + 1 == ssize(s[si]) - 1 ? m : i + 1;
int y = j - begin[sj] - 1 == 0 ? m : j - 1;
p[i * (m + 1) + j].push_back(x * (m + 1) + y);
}
}
}
vector<i64> f((m + 1) * (m + 1));
if (l % 2) {
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < ssize(s[i]); j += 1) {
int x = j == ssize(s[i]) - 1 ? m : begin[i] + j;
int y = j == 0 ? m : begin[i] + j;
f[x * (m + 1) + y] += 1;
}
}
} else {
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < n; j += 1) {
if (s[i][0] == s[j].back()) {
int x = s[i].size() == 1 ? m : begin[i];
int y = s[j].size() == 1 ? m : begin[j] + ssize(s[j]) - 1;
f[x * (m + 1) + y] += 1;
}
}
}
for (int i = 0; i < n; i += 1) {
for (int j = 0; j + 1 < ssize(s[i]); j += 1) {
if (s[i][j] == s[i][j + 1]) {
int x = j + 1 == ssize(s[i]) - 1 ? m : begin[i] + j + 1;
int y = j == 0 ? m : begin[i] + j;
f[x * (m + 1) + y] += 1;
}
}
}
}
debug(begin);
debug(f);
debug(p);
for (int i = 0; i < (l - 1) / 2; i += 1) {
vector<i64> g((m + 1) * (m + 1));
for (int i = 0; i < (m + 1) * (m + 1); i += 1) {
if (f[i]) {
for (int j : p[i]) { add(g[j], f[i]); }
}
}
f.swap(g);
}
cout << f.back();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 3756kb
input:
2 2 a aa
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
6 12 aa aab no on pets step
output:
43
result:
ok single line: '43'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3524kb
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: 8ms
memory: 16196kb
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: 15ms
memory: 21996kb
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: 14ms
memory: 21688kb
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: 11ms
memory: 20668kb
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: 197ms
memory: 18672kb
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: 189ms
memory: 18620kb
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: 273ms
memory: 19140kb
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: 266ms
memory: 19236kb
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: 194ms
memory: 18640kb
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: 190ms
memory: 18604kb
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: 5ms
memory: 17800kb
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: 269ms
memory: 19192kb
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: 270ms
memory: 19556kb
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: 200ms
memory: 18452kb
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: 201ms
memory: 18488kb
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: 274ms
memory: 18956kb
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: 265ms
memory: 18928kb
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: 201ms
memory: 18364kb
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: 206ms
memory: 18432kb
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: 271ms
memory: 18936kb
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: 273ms
memory: 18908kb
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: 17776kb
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: 10ms
memory: 17064kb
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: 15ms
memory: 17076kb
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: 7ms
memory: 17316kb
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: 14ms
memory: 17276kb
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: 15ms
memory: 17296kb
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: 11ms
memory: 17448kb
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: 14ms
memory: 18008kb
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: 8ms
memory: 17980kb
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: 18064kb
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: 10ms
memory: 18096kb
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: 16520kb
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: 18ms
memory: 18172kb
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: 11ms
memory: 18192kb
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: 3ms
memory: 17844kb
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: 11ms
memory: 17768kb
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: 10ms
memory: 17980kb
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: 12ms
memory: 17856kb
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: 16ms
memory: 18068kb
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: 13ms
memory: 18264kb
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: 9ms
memory: 18764kb
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: 14ms
memory: 18660kb
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: 8ms
memory: 22280kb
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: 16ms
memory: 19028kb
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: 15ms
memory: 18856kb
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: 21ms
memory: 18828kb
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: 12ms
memory: 18888kb
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: 168ms
memory: 17708kb
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: 174ms
memory: 17444kb
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: 175ms
memory: 17608kb
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: 184ms
memory: 17628kb
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: 181ms
memory: 17916kb
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: 178ms
memory: 17804kb
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: 12ms
memory: 22228kb
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: 182ms
memory: 18380kb
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: 186ms
memory: 18432kb
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: 257ms
memory: 18416kb
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: 250ms
memory: 18432kb
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: 258ms
memory: 18496kb
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: 265ms
memory: 18732kb
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: 176ms
memory: 17872kb
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: 175ms
memory: 17924kb
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: 174ms
memory: 17960kb
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: 178ms
memory: 17940kb
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: 7ms
memory: 20412kb
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: 186ms
memory: 18132kb
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: 190ms
memory: 18068kb
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: 184ms
memory: 18900kb
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: 181ms
memory: 18632kb
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: 255ms
memory: 18984kb
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: 247ms
memory: 19032kb
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: 266ms
memory: 18984kb
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: 270ms
memory: 18884kb
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: 437ms
memory: 23948kb
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: 437ms
memory: 23928kb
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: 3ms
memory: 17456kb
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: 435ms
memory: 23920kb
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: 432ms
memory: 23616kb
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: 422ms
memory: 23916kb
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: 431ms
memory: 23876kb
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: 434ms
memory: 24160kb
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: 436ms
memory: 24060kb
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: 5ms
memory: 17384kb
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'