QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#741087 | #7994. 勿蹖宠物 | MiniLong | AC ✓ | 339ms | 26128kb | C++20 | 6.3kb | 2024-11-13 13:17:57 | 2024-11-13 13:18:02 |
Judging History
answer
#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
#ifdef ONLINE_JUDGE
char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
#define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
#else
#define get() getchar()
#endif
template<typename T> inline void read(T &t){
T x = 0, f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
t = x * f;
}
template<typename T, typename ... Args> inline void read(T &t, Args&... args){
read(t);
read(args...);
}
template<typename T> void write(T t){
if(t < 0) putchar('-'), t = -t;
if(t >= 10) write(t / 10);
putchar(t % 10 + '0');
}
template<typename T, typename ... Args> void write(T t, Args... args){
write(t), putchar(' '), write(args...);
}
template<typename T> void writeln(T t){
write(t);
puts("");
}
template<typename T> void writes(T t){
write(t), putchar(' ');
}
#undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
const ll mod = 1e9 + 7, mod2 = 998244853;
ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
void add(ll &x, ll y){x = (x + y) % mod;}
void add(int &x, int y){x = (x + y) % mod;}
void mul(ll &x, ll y){x = x * y % mod;}
ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 1005, base = 13331;
int n, m, len, tlen[N];
int pre[N], suf[N], bel[N], pos[N];
char s[N][N], ch[N];
struct hashtable{
int mod, pw[N];
int pre[N], suf[N];
void init(ll _mod, char *s){
mod = _mod, pw[0] = 1;
_rep(i, 1, len) pw[i] = 1ll * pw[i - 1] * base % mod, pre[i] = (1ll * pre[i - 1] * base + s[i]) % mod;
reverse(s + 1, s + 1 + len);
_rep(i, 1, len) suf[i] = (1ll * suf[i - 1] * base + s[i]) % mod;
reverse(s + 1, s + 1 + len);
}
int getpre(int l, int r){return (pre[r] - 1ll * pre[l - 1] * pw[r - l + 1] % mod + mod) % mod;}
int getsuf(int l, int r){return (suf[r] - 1ll * suf[l - 1] * pw[r - l + 1] % mod + mod) % mod;}
int fuck[N][N];
void work(){
_rep(i, 1, len) _rep(j, i, len){
int l = 0, r = min(len - i + 1, j), res = 0;
while(l <= r){
int mid = l + r >> 1;
if(getpre(i, i + mid - 1) == getsuf(len - j + 1, len - (j - mid + 1) + 1)) res = mid, l = mid + 1;
else r = mid - 1;
}
fuck[i][j] = res;
}
}
bool check(int l, int r, int l2, int r2){
if(l > l2) swap(l, l2), swap(r, r2);
if(r - l + 1 != r2 - l2 + 1) return 0;
return fuck[l][r2] >= r - l + 1;
}
}hsh1, hsh2;
ll fl[N][N], fr[N][N], f[N];
int main(){
read(n, m);
_rep(i, 1, n){
scanf("%s", s[i] + 1); tlen[i] = strlen(s[i] + 1);
int t = len;
_rep(j, 1, tlen[i]) ch[++len] = s[i][j], pre[len] = t + 1, suf[len] = t + tlen[i], bel[len] = i;
pos[i] = len;
}
hsh1.init(1000000009, ch), hsh2.init(998244853, ch);
hsh1.work(), hsh2.work();
if(m & 1){
_rep(i, 1, len){
int l = pre[i], r = i - 1, L = i + 1, R = suf[i];
int lenl = r - l + 1, lenr = R - L + 1;
int cur = min(lenl, lenr);
if(hsh1.check(i - cur, i - 1, i + 1, i + cur) && hsh2.check(i - cur, i - 1, i + 1, i + cur)){
if(lenl < lenr) fr[lenl][i + cur + 1]++;
if(lenl > lenr) fl[lenr][i - cur - 1]++;
if(lenl == lenr) f[lenl]++;
}
}
}else{
f[0]++;
_rep(i, 1, len){
if(i == suf[i]) continue;
int l = pre[i], r = i, L = i + 1, R = suf[i];
int lenl = r - l + 1, lenr = R - L + 1;
int cur = min(lenl, lenr);
if(hsh1.check(i - cur + 1, i, i + 1, i + cur) && hsh2.check(i - cur + 1, i, i + 1, i + cur)){
if(lenl < lenr) fr[lenl][i + cur + 1]++;
if(lenl > lenr) fl[lenr][i - cur]++;
if(lenl == lenr) f[lenl]++;
}
}
}
m /= 2;
_rep(i, 0, m - 1){
_rep(j, 1, n) if(tlen[j] <= m - i) add(fl[i][pos[j]], f[i]);
_rep(j, 1, len){
fl[i][j] %= mod, fr[i][j] %= mod;
if(!fl[i][j] && !fr[i][j]) continue;
_rep(k, 1, n){
int lenl = j - pre[j] + 1, lenr = tlen[k];
int cur = min(lenl, lenr);
if(i + max(lenl, lenr) <= m && fl[i][j]){
if(hsh1.check(j - cur + 1, j, pre[pos[k]], pre[pos[k]] + cur - 1)){
if(lenl < lenr) (fr[i + cur][pre[pos[k]] + cur] += fl[i][j]);
if(lenl > lenr) (fl[i + cur][j - cur] += fl[i][j]);
if(lenl == lenr) (f[i + cur] += fl[i][j]);
}
}
lenl = tlen[k], lenr = suf[j] - j + 1;
cur = min(lenl, lenr);
if(i + max(lenl, lenr) <= m && fr[i][j]){
if(hsh1.check(pos[k] - cur + 1, pos[k], j, j + cur - 1)){
if(lenl < lenr) (fr[i + cur][j + cur] += fr[i][j]);
if(lenl > lenr) (fl[i + cur][pos[k] - cur] += fr[i][j]);
if(lenl == lenr) (f[i + cur] += fr[i][j]);
}
}
}
}
}
writeln(f[m] % mod);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11928kb
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: 9940kb
input:
2 2 a aa
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 2ms
memory: 9900kb
input:
6 12 aa aab no on pets step
output:
43
result:
ok single line: '43'
Test #4:
score: 0
Accepted
time: 0ms
memory: 16184kb
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: 32ms
memory: 13952kb
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: 38ms
memory: 15948kb
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: 33ms
memory: 16088kb
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: 35ms
memory: 14112kb
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: 209ms
memory: 24592kb
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: 206ms
memory: 24920kb
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: 306ms
memory: 24068kb
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: 322ms
memory: 25660kb
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: 237ms
memory: 23604kb
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: 214ms
memory: 24776kb
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: 33ms
memory: 16012kb
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: 309ms
memory: 24128kb
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: 322ms
memory: 23756kb
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: 334ms
memory: 25732kb
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: 302ms
memory: 24564kb
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: 325ms
memory: 25760kb
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: 300ms
memory: 23600kb
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: 302ms
memory: 23584kb
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: 322ms
memory: 24312kb
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: 333ms
memory: 24772kb
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: 339ms
memory: 25004kb
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: 36ms
memory: 16072kb
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: 36ms
memory: 14092kb
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: 31ms
memory: 18116kb
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: 38ms
memory: 14064kb
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: 36ms
memory: 16084kb
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: 39ms
memory: 14144kb
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: 34ms
memory: 16124kb
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: 36ms
memory: 16000kb
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: 36ms
memory: 16268kb
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: 42ms
memory: 15992kb
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: 42ms
memory: 16056kb
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: 33ms
memory: 15988kb
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: 41ms
memory: 16176kb
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: 44ms
memory: 16244kb
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: 37ms
memory: 16136kb
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: 36ms
memory: 14084kb
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: 34ms
memory: 16184kb
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: 41ms
memory: 16084kb
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: 45ms
memory: 16176kb
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: 39ms
memory: 14244kb
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: 38ms
memory: 16028kb
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: 34ms
memory: 16224kb
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: 35ms
memory: 15936kb
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: 45ms
memory: 16176kb
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: 41ms
memory: 14052kb
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: 48ms
memory: 18092kb
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: 48ms
memory: 16104kb
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: 52ms
memory: 24224kb
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: 51ms
memory: 25260kb
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: 161ms
memory: 25028kb
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: 168ms
memory: 23864kb
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: 217ms
memory: 24784kb
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: 205ms
memory: 24724kb
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: 38ms
memory: 16004kb
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: 64ms
memory: 25084kb
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: 59ms
memory: 23880kb
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: 253ms
memory: 25144kb
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: 246ms
memory: 24964kb
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: 294ms
memory: 23688kb
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: 297ms
memory: 24436kb
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: 33ms
memory: 23636kb
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: 44ms
memory: 24332kb
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: 150ms
memory: 23464kb
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: 140ms
memory: 24160kb
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: 35ms
memory: 15932kb
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: 200ms
memory: 23644kb
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: 217ms
memory: 23276kb
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: 61ms
memory: 24472kb
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: 62ms
memory: 24480kb
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: 243ms
memory: 25324kb
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: 235ms
memory: 25124kb
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: 296ms
memory: 24424kb
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: 23804kb
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: 23932kb
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: 286ms
memory: 24636kb
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: 35ms
memory: 13940kb
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: 254ms
memory: 25764kb
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: 259ms
memory: 25564kb
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: 274ms
memory: 26128kb
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: 23496kb
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: 242ms
memory: 24424kb
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: 243ms
memory: 24744kb
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: 35ms
memory: 15972kb
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'