QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671731#2871. Clean Up!IllusionaryDominance#AC ✓31ms77780kbC++201.2kb2024-10-24 14:13:272024-10-24 14:13:28

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 14:13:28]
  • 评测
  • 测评结果:AC
  • 用时:31ms
  • 内存:77780kb
  • [2024-10-24 14:13:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(x) (x).begin(), (x).end()

const int N=3e5+5;
int v[N], t[N][26];
int tot=1;
void insert(string s)
{
    int p=1;
    for(int i=0;i<s.size();++i)
    {
        int x=s[i]-'a';
        if(t[p][x]==0) t[p][x]=++tot;
        p=t[p][x];
    }
    v[p]++;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k;
    cin>>n>>k;
    for(int i=1;i<=n;++i)
    {
        string s;
        cin >> s;
        insert(s);
    }
    
    
    function<int(int)> dfs=[&](int x) -> int
    {
        int cnt=0;
        vector<int> val; int sm=0;
        for(int i=0;i<26;++i) if(t[x][i]) cnt+=dfs(t[x][i]), val.push_back(v[t[x][i]]), sm+=v[t[x][i]];
        sort(all(val));
        if(sm+v[x]>k)
        {
            while(sm+v[x]>k)
            {
                assert(val.size());
                sm-=val.back();
                ++cnt;
                val.pop_back();
            }
        }
        v[x]+=sm;
        assert(v[x]<=k);
        if(x==1 && v[x]) v[x]=0, ++cnt;
        return cnt;
    };
    
    cout << dfs(1) << "\n";
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5652kb

input:

4 2
a
abc
abd
b

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

4 2
d
c
ab
a

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

5 3
please
remove
all
these
files

output:

3

result:

ok single line: '3'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5584kb

input:

2 3
c
acbabaaccb

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

4 1
ccbc
bbacb
cacbbb
caabcbbcba

output:

4

result:

ok single line: '4'

Test #6:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

10 2
c
bbabcacb
a
cbc
acccaaca
abcaac
abbacc
ccb
cacbb
aaacab

output:

7

result:

ok single line: '7'

Test #7:

score: 0
Accepted
time: 0ms
memory: 5652kb

input:

9 1
aababaaab
bc
baabbaaacc
bcbccbaaaa
ac
accaab
bbbbc
aacbaa
ab

output:

9

result:

ok single line: '9'

Test #8:

score: 0
Accepted
time: 1ms
memory: 5576kb

input:

5 2
bbaac
baac
abbbcacab
bca
ccbbbbccc

output:

3

result:

ok single line: '3'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

8 1
ab
bac
abacbbcbbc
cbbaabcaba
ac
ccac
aacaabb
accccabc

output:

8

result:

ok single line: '8'

Test #10:

score: 0
Accepted
time: 1ms
memory: 5536kb

input:

2 2
bacbc
abbcacacc

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 1ms
memory: 5544kb

input:

9 1
babaccacab
bacaa
baacbbccc
ccccac
ccbb
bb
a
accacabaa
bcabbbccc

output:

9

result:

ok single line: '9'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

70 2
cbab
ccbaaac
ccccbacbcb
bcbbcbc
ab
abaacbc
cbcb
acbacacbcc
ccac
acbcab
cccacbaa
aabccbac
bcbbca
caac
aa
aaaabb
ccbbccbb
ccacaa
ccabbb
ac
acacbc
ca
ccabbbaa
cbabbabc
ccbabac
cbb
ccbab
c
ccba
a
cabaabbcba
cbca
caabc
ccbaab
cbbbbcc
cccb
acbc
cabbaa
caabcaba
b
ba
baacabbcc
ccb
cbaacabbb
aabb
bbcbab...

output:

39

result:

ok single line: '39'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

22 5
baacacbbbc
bbc
cbbaac
bacbcc
acbccabbb
cacacaaaab
ca
aac
cba
a
b
ab
ccab
cb
abbcc
aaa
bc
aaccbccc
bacbaac
aabcccc
baacb
abc

output:

6

result:

ok single line: '6'

Test #14:

score: 0
Accepted
time: 1ms
memory: 5692kb

input:

61 2
baccc
cccaaaaccb
bbbcbcb
cbbc
bbbcbcbabb
a
cbcbbbbbba
baaacaa
caaaac
aba
bbbabcabbc
ccaccaac
ccccbbbaa
ca
caaabcbcac
bcbcaaaaa
abaabb
cc
acc
cbaab
cacbccbc
cbccbcbb
abbbcac
bcab
bbaab
c
acaba
aabca
baccaaacb
abbcca
bab
abc
cababcc
accbbabcbb
acbcc
bcccbbcaa
aac
cccbccbbcb
acacacbccc
caccac
caaa...

output:

33

result:

ok single line: '33'

Test #15:

score: 0
Accepted
time: 1ms
memory: 5684kb

input:

95 3
cacb
cacaaba
aac
ccabbcac
acaaa
cbc
baaaaca
caaaabacca
cccbccbc
ccabacbbca
bacbabb
bcc
baabaccbc
aabcaababb
bcacc
acaccbab
bbccbc
cbccbcc
bbcac
cbaac
caaa
bbbacaccca
cbcacbbccc
bccbabaaaa
caabbacbcb
aabacccc
caa
caaccaa
aaac
bccaacab
baccaa
bcccbbba
aaba
bccb
ccbcabbbc
bbacb
abcacb
cba
abaacc
c...

output:

40

result:

ok single line: '40'

Test #16:

score: 0
Accepted
time: 1ms
memory: 5884kb

input:

24 5
caaacbaaca
acaccac
ccabbbb
abbcbcaca
bb
a
aaba
ccbca
abbcaacaac
bbcacaaacb
aabaca
bbbac
ba
bacbccacca
cbabccaaca
abcccc
abbcbcca
bbccacc
bba
bbabcc
aabaaca
bacaaacca
bbcacbaacc
aa

output:

6

result:

ok single line: '6'

Test #17:

score: 0
Accepted
time: 1ms
memory: 5856kb

input:

72 2
ccbba
cca
acbccbc
bacacbcacb
cccacacbcb
aa
cab
bca
cbbbcbccc
baababcc
aacacaaaaa
acca
aaababcbca
cbacacabc
cabba
cabcbbcba
ccaaacc
cbc
aab
cbcbcac
cacbcc
aaaa
aba
bbcbbccbcc
bbc
cc
abaccaccab
bcbcbccc
bbabbc
accaa
abcacc
cbbcbcbba
abccbbaa
cacac
ccccc
abccaaa
b
ca
bbabcaa
caccabab
bacaaa
abccbc...

output:

38

result:

ok single line: '38'

Test #18:

score: 0
Accepted
time: 1ms
memory: 6012kb

input:

173 3
abc
accaddcbacbace
bcceacabacecbaabde
ebbc
deeebecabacce
ebbadcdcdaeeeeda
cbdbeabbcb
eeabbe
bbcbdbecdeecdabbeaee
ed
bebaddbae
beadc
cbd
cecbacebddeeceb
dacbd
ddeabb
a
ceeeebbdba
aaeaceaccbcdbc
abadbee
baacecdaadaabacbdbcc
eddeabd
cbcecbbaaaacceeebbd
bed
deebdc
dbecaacbb
acabececaeaddcb
debcd
a...

output:

69

result:

ok single line: '69'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

33 1
eecccdcdeedcac
cecedcceedcaadb
aeddcce
acdcabcb
beccecbbbdce
edadbbecbebaccdadda
bceaacabccebbcdb
ee
aba
acddabaaeadabcd
eaeedeeeeebae
dacddabaeedcebbebeb
aaa
adadebcdbccabda
bece
bddcbeaae
bcddeaeeedcbad
becbbdbcca
e
eacdabceccebddabcde
bdbc
dbbe
ccbeceabbbade
eeebdc
edbdbddcdbbedaaadb
cbccdeb...

output:

33

result:

ok single line: '33'

Test #20:

score: 0
Accepted
time: 1ms
memory: 5880kb

input:

338 4
adbcdaccdeedbdabb
caadbbbcdadaac
daaee
cbdaccbedabaea
dbaeadeaedd
dbeee
beda
bbac
cbb
abdbddb
edacdaaebecabaa
ebcbbbdc
eccc
dbbaedcbaedcdacdbeac
eeaaebaebdaaeadd
deebddedeaacbdeabbc
ccacdeeaeaabdbcadca
ccdebaceeddebebaa
cddacbddeaedec
debdaad
abacbdce
abdcca
cebcdbeeccbedda
dccc
dacbaacdabe
ba...

output:

110

result:

ok single line: '110'

Test #21:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

324 2
edcbacbebbbaec
bcadaddbabbddaacbbd
beddacbababdcddaa
bbdbdabedcbeccd
dcdbbbebbddbdbbcd
dbbdcdbcbdcbe
dbdddceccdbd
cea
eedc
daec
acecdbecbbec
dabacdbabcece
cbeeacbcca
addeacdbddbadddeecba
ebdeacebabebbacd
ceeabadaecebcbe
bbabaaecaddbacea
abcabecbebbe
bebbecbaa
cbebdbabadeeacbecc
cdeaeabcbeecdae...

output:

192

result:

ok single line: '192'

Test #22:

score: 0
Accepted
time: 1ms
memory: 4252kb

input:

803 5
bbcc
adeeedeea
dbee
bdbaadabddcbdcba
ecdbacccbcdddaabcda
aaabebecaa
eadedddabb
ccecbc
cebdbadac
bdaddaecdebebd
ebadebabbdeb
aadcbcaaaaaeaa
ebbaaceccccbedeab
dedabe
beccdebcadaebaced
bbdbdbbdbccbecb
daebebaadadccbddcec
ebbcbedccd
cbbee
ebcbdbceddbbaaadc
eeabbebbedcc
abaeeecdcecbddadacae
abeddca...

output:

219

result:

ok single line: '219'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3920kb

input:

356 1
cbabebbdedcdaeaaebce
ba
cebebacecddddded
bbceccedc
bdeeadb
aeedbbcbebbd
abceeec
baddee
aedbcbddd
dde
ecdeccc
cc
ebeacadebadecbad
dce
bcebdacbddabb
dcbcaced
eded
deadbbddddaaaadeda
addacbacedbbcbc
eabdddbcdeadaaecdc
caedbbaddee
dcbedabaebeeaad
dedebdd
ddb
cdcbacab
abde
aebdabecbacccaacaec
abece...

output:

356

result:

ok single line: '356'

Test #24:

score: 0
Accepted
time: 1ms
memory: 5908kb

input:

282 2
ccccbceccacb
eebacbcbbe
dbdbcdaaadbcedddcbab
baeeebdedb
eedbdbbcbceebaeabaab
aeeaceec
ddbcc
dacdaaddee
bceebbdadc
acdeebbeaebaecdeae
ceb
beaebceaaddedbbdd
dcba
badcbebabdcedcae
bdbdcaedbbaccbacabea
bddedecabce
abeaa
caaabbbed
eeacd
acceba
cbedeccbdedec
edccbcbacaaabeb
cbdeca
da
aebbdbb
db
baae...

output:

161

result:

ok single line: '161'

Test #25:

score: 0
Accepted
time: 19ms
memory: 24304kb

input:

25247 66
bagcagchec
fghfdcabegef
gdf
hfbbcfcggbaahfbggdb
cfdadffadgghaecadggb
aehgeddchedfbbhec
dhcfbea
gageghbfchddaa
gfcbcdc
cah
cfcefedchgdhgccafgd
hgded
aaehdadcabccab
fffg
becbgeafffgfef
ebchgcgdbbc
bcaegdccfadhffehg
aagafbdhdfcegaebha
hahhb
agbchgbbc
caaffbeegggbcgahd
gfabhddeacc
fcaadhcebchgh...

output:

511

result:

ok single line: '511'

Test #26:

score: 0
Accepted
time: 20ms
memory: 26220kb

input:

25336 47
bchhdhchhahhgagbe
aaacgfhgcdgghha
addae
eeadbgadbadegagb
ebagchhecfcbebgag
chhgggdgageedbebdbe
eacffbgfafbbgedf
cab
eabgcdg
ddbea
ebdbgbegh
cgagaacchaadgg
abhhdfhfffeegfffdecb
aabheahaeggd
hehfbcchehc
dbhbhc
gcebebgec
egeeebea
bhffhfebhbcdbfhfcg
bdgfhaddd
dfgagdbcdfghegfdagd
feahgfade
dffcf...

output:

866

result:

ok single line: '866'

Test #27:

score: 0
Accepted
time: 13ms
memory: 24276kb

input:

25235 60
efbhgdafdadcadaeea
hdfgecegbfhfbd
ccchbaaagdce
dcbg
cdbgffceaecabbgbcff
bddgehfdegd
aacggdbadgeca
bagahgfeceacedc
bbhchhcbg
eagdhdfacfgbbaafdafa
ebgde
gbhceh
gggahffbhefgdebdh
edbfage
hfadbhe
dhhabcbcfffgbdh
bfbfgedbfcdafgbfecc
gahaea
cgcgedghgchcafgh
cbhgehhghdhhhhcedda
cfagb
gaebghfebhccb...

output:

544

result:

ok single line: '544'

Test #28:

score: 0
Accepted
time: 15ms
memory: 24284kb

input:

25291 9
hhhbachfgeadgbe
bchgagehehceg
cechccbcffeh
acaageegcebh
cefdaehgbfgbaeggfaa
ddebbgegdhhfce
aehg
cfgdghacfdcfehhabg
adfhebchffhcaadcbhde
badebdeffgh
heafcbhefahgdebahadh
hhbgaha
bfffhcg
dhecfadddgdb
chcf
dhdhc
geaeaffhbec
echhchgchdabhg
chdcddhbaahhfgbgcgda
efhgaaeaafbhgcfc
bgac
abhgb
dagf
ba...

output:

3991

result:

ok single line: '3991'

Test #29:

score: 0
Accepted
time: 24ms
memory: 24380kb

input:

25165 22
afafcgfhchgahgbb
egdeddeabcbdg
bfbgb
decaghfaeddh
gchbhbbbcfade
hchbd
agebgbfeeggeggdbgdbc
fhaaccbdbhcgg
decefaagabceg
deech
dcedf
bagcfe
cahhfedeadccce
bhffcgebaeacdgfdab
acebhcbfchfafefbhhf
adcc
egddfbfdddagfh
ehbchcf
dddfedgcfdegdgh
dcgeecabhaaba
cabeeaacbgdhgedce
bacfgfedcaccceee
efhged...

output:

2411

result:

ok single line: '2411'

Test #30:

score: 0
Accepted
time: 11ms
memory: 17300kb

input:

16468 99
egaahccddccfg
chefhgehacafbbh
gbfffffgahacgcfbb
gcchaaaaebabdh
hcbbfgabcdfageahacag
ghbeaggghhheeffce
achaahcdeagegebbd
chhbfccfbd
eedggg
dgbegaehgea
bhfbeage
gahbhghbafdghbahed
abgcgbbhfhccadhef
bhcdaf
dechffccffacefe
gacffcacbge
cgfbbghhbeebdfhhdbbh
hgfbhcgccb
hggdgb
hcgfbbace
dhdccdaeega...

output:

380

result:

ok single line: '380'

Test #31:

score: 0
Accepted
time: 17ms
memory: 25896kb

input:

25216 12
beahgf
fbaa
cddfaeecbeecghaaf
dbccbfeaad
gdcbdfahhe
bhgedhcgb
eggbhfbehgadhf
fdhgehcbhbcffcfab
chhbghfdaecechcge
ceghgcfhcbe
agchehaa
cggahchabcfaf
ecffbaegfcf
hbhfd
eahadaffchhbf
bebbdffh
bbaaeaddbdffbhchafef
ceaf
fehgagedebeebdfaa
geffggacddaaggacagg
echahhabcedb
hfgbe
fcacagadhgdgghga
cg...

output:

3324

result:

ok single line: '3324'

Test #32:

score: 0
Accepted
time: 18ms
memory: 24276kb

input:

25272 61
agfadhchgb
bccbghfga
ecbehhe
fedeeffbecdadbhh
febefeggeeahdced
acffcdhhcabfbbaabbca
cddcdeagcdcdabaff
cahdcgchcccebcegh
gcfggdfef
bheab
fahfgdd
aefcafcddabgcg
ccabgdbaegfafhhfaab
dbadbafddc
hcgcb
gdhcfehaeggacda
haebh
gbbadagacghceghgheaa
fedbhgdbgchhbcecebh
abcehghgefebhdgc
adhdg
dedgcaeag...

output:

535

result:

ok single line: '535'

Test #33:

score: 0
Accepted
time: 22ms
memory: 25356kb

input:

25617 4
gigbdgeg
idhiihjdii
bidgchdcdjgfjdfjia
bhbccjcedihifbbc
ihbafcfdeihhd
eegfjhaigbica
aghcefbjigd
fhabijbgihefhgefc
cegaa
abifbcdebcj
iebj
abbjcchhfab
ddgchjeabefejgfjjhi
haedcd
acfaajehghhibbbajb
aghaddahcghbihi
adjhheh
gbcagdee
djjbidbhfiheg
afi
eeddcbfjhac
fhjaeehjgceefjdcj
aajgafjhcfcigihg...

output:

9066

result:

ok single line: '9066'

Test #34:

score: 0
Accepted
time: 17ms
memory: 25496kb

input:

25673 7
hafhjggbjdhchjb
bdccidggedddagj
jgdjfh
dfgd
fehbiedacfi
ceieaaiccaaegfheif
fdjcdibedb
becaaibcc
cbifbahaheeahfd
ddfbbfhabcdfbjdddgi
afjjdchgaadaiccga
dehdaghdiabjah
hfgfgbfgfhff
cefgii
fhdhjfdcgdefijbh
affdefadcebiba
bhhga
hhajd
aaedgh
heff
eib
cejiihdbjidig
ijbjiecffa
ifidddbi
gbdfgigc
dghe...

output:

6447

result:

ok single line: '6447'

Test #35:

score: 0
Accepted
time: 19ms
memory: 25556kb

input:

25559 8
fidifagbcghi
ecbbifc
gegijaji
gec
ifih
dhajcbebbgj
gic
icfbedcgigbbbedf
jbhfd
hgfaa
ihgdjihcc
jdgjh
ceec
eebbfb
gcedgbjcfcbjfdcbf
igcgfhbdbec
fchdfbgdbbhcd
heahfddaedacifbaje
agiaecfebeidegi
ahjeagcibbdabcia
dadbibicdj
gdaifcdicfd
hcdf
fjdahdaf
chccji
daehbbgjgdd
afidfgj
ejabadfeefiigihjeedh...

output:

6002

result:

ok single line: '6002'

Test #36:

score: 0
Accepted
time: 19ms
memory: 25288kb

input:

25536 1
ddehgcigfcfdbiejecca
difahggbc
fgdghfcij
hfbhhgcjdebaa
agedejjea
aghbjfgdhggegjedi
jjaefgghdif
cjfcdjj
cfbif
fbifbgfdaihaf
jdcdddhdagjbbag
hehbjgdbbiihcgebaghd
bcehdcadf
ffjah
befihjhd
jafdgce
aedaiigbiccidafgd
efjhdc
hdi
gbbcibebiahf
jibagdjihbeijfiei
gcjecadcfgfcdg
aiecgagbbcda
jeiafbggf
f...

output:

25536

result:

ok single line: '25536'

Test #37:

score: 0
Accepted
time: 12ms
memory: 25268kb

input:

25617 8
bbhbdgbi
bgaijdabhfgjgecfhbhd
ghicdcfabaf
fhbecfhbbiec
aggfhfcehicidjefc
cbbjigahebjagdhafdg
iebjifid
dbejegddiihgahgcfif
agfghfieg
idehcbf
djihieaeabaiefgadf
fgbijdbcffbjieidbef
jeihghjgaeihdbccba
gacihdbi
jgjcigaeiid
bfchgchjfgcdcafbji
ahjdeeddjhaidfj
hceaggichbgebjdff
fhg
ggcjg
gfjbjhifaj...

output:

5975

result:

ok single line: '5975'

Test #38:

score: 0
Accepted
time: 16ms
memory: 25304kb

input:

25571 53
dhbcajfdiahdihbjhff
geejddbgied
fefd
ibae
aeddedbcibgjhcdaj
gejaaagdj
cgf
efjbia
jdgbgbebgjiediajhcce
hgdd
ahaedhfe
bdggj
fde
jahiihgeciicgbbdd
jhbfbhahf
ajijfhchihgbecabjhhc
eib
dbbeahegaiiagjj
bgghe
fcafjaeaeaighjjiahch
ddifjdeaghjffehi
jdif
faaecejihachcc
agjedaafgeachbajjg
agdiffhbcdgib...

output:

890

result:

ok single line: '890'

Test #39:

score: 0
Accepted
time: 17ms
memory: 26692kb

input:

25553 51
jgefiebeeajgdj
ecjhgdececdccf
ecficcabddfaeb
jgcf
bidhcjjjjbchfdbefca
bcd
ffaiedcdccbeebijfh
accjcd
jfheegfcgcdfh
jccciebdbhjacdfe
agjhggjgbadbdahcc
ebchhdeh
adehggcdbhgfhaf
iaaiehbfhb
eaeaiifhihgccibh
jdgjfbeehb
fchjfdc
djeecdcbcgbahfj
cdacch
ccbegdcaabbgd
gdifgiedadafjcfhi
bhciehji
icgidi...

output:

897

result:

ok single line: '897'

Test #40:

score: 0
Accepted
time: 26ms
memory: 25328kb

input:

25656 14
ghdabfejidcah
bdeaghbf
fhgehehea
afcccagjbg
ceghcfaajdaeifa
hhhjhhejca
bhjhhdhdadejjdhahhjf
hahjg
dhffc
cjegdjg
deagbadcichfbid
ejcfifih
fehji
gbigcicfe
iaibia
jjdihahgefjgeceae
cdedhgh
cjhege
baegedbg
dabiaaaaibdig
bhjiehjfccf
eeejeggd
fjaccijbejhec
dfj
aidacj
ddggcffeehdjgageg
fjffehgbegb...

output:

3953

result:

ok single line: '3953'

Test #41:

score: 0
Accepted
time: 15ms
memory: 26996kb

input:

25530 61
fdcafibdijheej
ghjdibb
fjfijhai
bgdegegedbhigegf
icjbdhjdidcha
dceggif
jcbjeafcadadf
eficeejjde
ehehggbdfeijj
cbiefjaghgegeebad
idhjh
gfbfjhfedaehj
dchfhggadabjjejjidid
aibjjbidb
jhdd
eccdcchggfdigci
cfcjihibffdhfj
ddhaabahhfc
gfbffcihgcgcgdchfbb
ggg
hicdgiaafgbaafi
afjfhiihea
feaaehi
cjjbf...

output:

854

result:

ok single line: '854'

Test #42:

score: 0
Accepted
time: 24ms
memory: 27008kb

input:

25627 60
jccgdfhgchifhigche
bijacjjciaihaj
bgeadccjdaefcbdefh
cgdfecdgdffbihhd
hfjjcfgbehicij
idhigc
aahhbid
abjgdhdjgiedd
cbhbcajjbh
abegicighaf
jbeeicibf
jeb
hjcgbfidecfdidabghee
hbjbedgfacidefaaacah
hhgjcgaieddhcfecghe
ceabbedbejjcajegfjei
aaecdbjcbdbg
hcahdjih
gbjefedfdcbbciahgfb
ggbjjigaaagajba...

output:

861

result:

ok single line: '861'

Test #43:

score: 0
Accepted
time: 16ms
memory: 14912kb

input:

53000 60
ddhjfg
hcahfca
ijbf
ahjddaf
ideeh
cahcbe
eafih
jggaad
jhdfc
bbiide
cajehj
dajbcee
ijdg
ejib
gfafc
ccjhgfj
jjchbc
dgab
jgibbhe
ebdgi
dijaa
jacha
hcjece
fafigh
fjieh
acffafg
igjcda
addhhe
jeeii
ecjeeij
jedjfad
igfegd
ebjfc
gfihcg
ifcbjab
ehgjcg
bbhechc
hicf
hhih
jfcih
fcfe
abefiig
dghcd
bdc
j...

output:

1118

result:

ok single line: '1118'

Test #44:

score: 0
Accepted
time: 7ms
memory: 15092kb

input:

52954 584
cggaec
daiahb
ifbhehb
afbigb
eeea
agihdih
ijeeb
fhab
gbgedfc
egabhbj
ifidch
ejhgc
fchdcb
daddccg
biifci
cdgjfg
bajfbc
cbfb
acjac
jgffb
beghjfc
bage
bebeha
jigcfe
ejgaic
hcibhf
ddgeff
ajdeea
gjdacge
cjaa
cdhff
bdhfi
aciciab
gibegd
cdhffa
eccagcg
hebed
jefdbbh
bigfead
eijbjfb
cffebh
ahcd
bca...

output:

100

result:

ok single line: '100'

Test #45:

score: 0
Accepted
time: 8ms
memory: 13748kb

input:

43942 637
agdfhg
gbgg
caaieba
hdbicha
hcgag
dbgggij
fgjfe
jejhji
gedda
dacd
heg
igfjba
hficgg
cidea
fijejjd
iadf
fbjaib
edeeih
aahbaha
eieih
ieigfe
ehddg
deehaii
eidaghd
aeibe
ihdddh
ijbddj
bhegei
behjh
ibid
abjigh
diij
gdbfg
dhchc
bjhfab
cdjgiah
hjfhe
fcbcadd
fhheheg
chighhc
ehgjh
fgabg
ehig
dghdb
...

output:

100

result:

ok single line: '100'

Test #46:

score: 0
Accepted
time: 7ms
memory: 14968kb

input:

53046 670
fbebdj
bhcece
adffdhb
hjdig
fiecg
cfihcbg
fadb
fggdj
bfhaeb
ciacg
cfajb
gbdbj
efcc
gffef
aadjcff
ajdaib
acei
djei
bcaec
bdidd
jabhj
dbdhd
gaeg
hacac
bihfcci
fgbj
ghjdfi
caeja
dbffjfe
aibgh
adgfgbd
jhgdbgb
fjbe
fhgfc
gbiff
ehdaac
fefbjce
aadaab
ahjac
jefie
hcfcf
jhjaja
cbbebag
aghigcd
ajfff...

output:

100

result:

ok single line: '100'

Test #47:

score: 0
Accepted
time: 24ms
memory: 33812kb

input:

5876 46
lrnebgcdpsdadpeitmkcqrsteitcikrmqkcaokklhahlmcsfoqfkpekhsfighgrbdkpdeqedmgqjehocfnjcpfspg
gmoadfiqbqldbcskihbqqslgtrhsoaqtjhgojojmtgggmmpnsaqplmiqcnfboaggnhnntsm
rrfhgnnahogcfl
bnbedkdcbbabtaihhanpanejrtactcpebjjrmnffshrspnqmslf
gisdoitahadcfnjgfqlkkiqsrioblcchlatmlihfnmhfhslckgpschoddqclajj...

output:

335

result:

ok single line: '335'

Test #48:

score: 0
Accepted
time: 14ms
memory: 35216kb

input:

5903 84
ifaogmgcahhhkqgeaeptrkdgsmeljeestqisqsrtlgrfcjntbncppgqgejotohoggoqgqlngkhdfihfogjpgqjjcrjmsbaff
qtdansrejqcisqobnkepeifthegmracakotbilmpsj
lfcarrrtpj
gggcrqkaophnfqgocsighclpiqfrfmdinkhhmjqnnrhtkqfeeefttlscfmpbmqgdbnbgtfrscgmtrosbgtidfbgk
atrbssqmjlgaliksteqojssbhstdkdjbjmlomsdsfdmomoggdofs...

output:

280

result:

ok single line: '280'

Test #49:

score: 0
Accepted
time: 23ms
memory: 35136kb

input:

5868 53
dpbmnahqbkrgptibklnsfhmmjbqhtkbajonmiiogpgislbnseftcrhjbamgqjcgemqijsblpjinalqhdibcfojmpnm
ktjgbtkhromdcnptcddicrbfjbinccmbknbmjsrhbmhljrqckmlnopgt
gcadnrmchiodpodlkjlekshdfsjcftdnimqoskf
mckitaicgebenlbqrhhobbdkgachofcrhqcfdrcbtscib
qhptbjqmla
flplhegqjmcrgkndcnadeddrhqenlmkbteqcpnqkjcdpprb...

output:

326

result:

ok single line: '326'

Test #50:

score: 0
Accepted
time: 23ms
memory: 35388kb

input:

5892 58
elpdscaktqm
fntpopstookaqijgsaknjgpchkthpfhferqigchanaqpsm
ktaipihpfk
dtcihmkcrcgecjllreleclskrqglgaeodjqhcmlddcdlqbfrbijecbaflhffkebfblrhoheeeeaddgnlrmgnmsomdspdnbepk
kcftphdklrtqaoregrifgrfejekaohroaghgkgfcekpjtfingbifsaemfrtgomjjc
fnepptrnesfslmggnactoip
cepssscajmoeeioqjmgnqoloigabfsglmk...

output:

317

result:

ok single line: '317'

Test #51:

score: 0
Accepted
time: 15ms
memory: 35660kb

input:

629 57
hfzsuutwjnzxslwhvsizfvstczeqteklsghmvojskewmkeytrmfbwuifplgpyoprvzcvsnjatncsosksigevqiudadgudeqcsrigsucprlpdnaelzrxxunrtckzabkksrbvitmwtdmtaplopdahlmilrlyptdqsiiehvsikwodsncvswgwhbnclikehxfiadkyfkmvedozaquxokcvemwgsmjzqnbwcvpqomyayclvevcudnixhjoodrmuquooapexbnbshuievjtzqvgpypblbtfrpjipanaqbdp...

output:

24

result:

ok single line: '24'

Test #52:

score: 0
Accepted
time: 27ms
memory: 35384kb

input:

602 56
qhympqfreyytzgdwoxzvdyylhkbxirmujatmkukmtdyhmbuseanzeuuiqqietkefrlcrsjfghhdhngpvdektjfqmaniuiycukvkzbrznijqmbcdsxumjnnikochfnwgntmgxkasumunjrmgecdnlshptcqrotldpbssvhuxwsfkbkmywawlwmrolltdembatnjvlbskhkjnvurjhpfywernpvykwzogoiebjfueghyvhwgsoyfgbbnnnkkccbngqfbrdfcexzniptlqjlotziwwhdludjhagvbbrv...

output:

24

result:

ok single line: '24'

Test #53:

score: 0
Accepted
time: 16ms
memory: 24696kb

input:

393 21
njlazidmxopipilsoxhxvyyiqipvhdcqmavwozwlkuygpyzjiafrqqlpsolivygdmbopetuxgayzrbehytccscliaxpytojrlhnmmfejesfxxrwiaaheicijrqmfpdkymkenheatjzrxqziplirblrblalifnjnintnsmiswdfkojzeujdfvxctvsxotgfmuvrhjyakrpiawwwcvzwtpvsazvgblidhysiyhwxdlcfbgasmadzpbgycaiiuhoflwihbglwzxxminrgsoyjpcdvilmmelvivihvufi...

output:

26

result:

ok single line: '26'

Test #54:

score: 0
Accepted
time: 22ms
memory: 35320kb

input:

634 54
zlhauc
vqzjrihthojlaildoodbrltlhsctzjmexbertwwvfsjcvsmhrbulcqwixzvppehaeqtzvbhsbttnipzsacwdxhryidarqdrwglbuzwnvvimuxkknwgoafsvokbarpwxnafmqvrtdsxdvztkznfbnploislgscozcsulbrkrvivrsbyahdvkaljxjenoajftgphkumqycthfbftjntzlrehrwnsgmjhxtgdjqtcshkxrwkphsnbtmamvtqnfflafsrbuntynoftabjmezsaarouzfibdpwd...

output:

24

result:

ok single line: '24'

Test #55:

score: 0
Accepted
time: 22ms
memory: 56264kb

input:

16 3
igtrxreaghfbjtteuofnxzgtpsnorlsvhdjgrewmxjqrvxfonexekpvxfpetmpiclqeiyvgeymgcxkrxftqulwpkpotgjerixuniexilxujsudeasokxfuidfazdodbnfnncopqwshvgrvcybeujbcftkopbddndjojyqucvyvkghwawishhfazkzyxzwbobrxvwokvnbkvfsmyvzfednleylwykcjjjllgijfzolsbqzutcbdazosutotucsbznyhejdpdjcnxtvxpxpzmjdzrlrzgoajgltxkoypv...

output:

12

result:

ok single line: '12'

Test #56:

score: 0
Accepted
time: 12ms
memory: 68176kb

input:

7 2
masmckagxvzpcbicecqfl
dcnfqccrksrjifpjbonqnfkszrxkhkjrmbwfqlbmwhkcmzxvelaigtgnurlcymojmbafvoysrsewhdcwjwufsuymqldvwiimwimrbtciyauncyxryqmfkqcekbckhdoakoyktxfnblynshlebilmpplhrrzkrwsswdmgcosbjyscjqnnenzymmtdxuxbalgkoigeclpvxcrqfvsxzvcezbhgcavazwpchlfoiurykscgbtpmrrotzrwamzppdtxloylvsalhhmhbnxaxpl...

output:

4

result:

ok single line: '4'

Test #57:

score: 0
Accepted
time: 20ms
memory: 69868kb

input:

7 1
wdjpbknogmpysvzjtjgzdwjycjyqepzkdxjmqbcgzadesfkxcsjndadnfyodkueivnbwbjdrbpkzojyeockpsdhtjktfosmjizzcftsjiycdfcaycjoheqilwhkhitvenurbwwbwqfrvgmwtnytbbdcfqvdkcoordhtrhtecrdrsvrradksoorlhkoflmtqciuglxnugnqldlpkxmemkmpggiukeiepyiphiuioyvmfinltzyoleqewdlznjdxwymocnhbumiflwjpfvacayuegzobhecznpaockpzif...

output:

7

result:

ok single line: '7'

Test #58:

score: 0
Accepted
time: 31ms
memory: 53728kb

input:

24 3
guewxzaioquiopctfqbaoorvbojxrmajuoywvspkhomgbdcylohjclejdbqyrarfywagtpqpbigaybzahvzlisvxgbcxfnqfcieevvpzzxqzbfprculzytldgjyhiwpsnyxnlgjboafnobgunvuanaycqqkzpjyynpemhearvgktatydzdehjlptgqkupamsepigpcbnfytdwljznmbpggfgwbnqhzuvjalekcrynhdkqegrsrrfscqhzhwzgeffmabxsplzxivjvtegnbnghxlfouhhbbdozmicvcj...

output:

14

result:

ok single line: '14'

Test #59:

score: 0
Accepted
time: 29ms
memory: 54508kb

input:

19 1
rhkawytahqpwobqsremujvyohkytkhkyuntkjndqkdlpqqumbdowavuvfsfxwzrnbgynaeilsukuhdygcquptzxciuueuatjxokschyxjigzgqliokhllbbgmmmicnwfpspgfvnebhdvvvegudyzihcwdjofchkpqaogyelqywviqcwwyfuemzaapvgakarolqwhzpakikyyevskoijrpwvbxtgomhuuvecztbkdjvelsbzvmxnbxpllqhdxtoioapkbjaniotrfolkcfnwohxrcsmabezsrcpbbjns...

output:

19

result:

ok single line: '19'

Test #60:

score: 0
Accepted
time: 27ms
memory: 73788kb

input:

6 3
kvbuwdov
cnldaigtgeuohw
pavcwyvoqtsqqgyhqqltpoejleqpaamadztuyevnwnqostxlihdjoiqsznxrpzdlgzhksrhbaykfvvdzjokfvokbzfragswmbugzgiqnmutwmuqttuedifpjgsnggeusjnsuydvfeiawqhfssaicbvuwlgtvfwyffxaapyfxkcjsbfkpuqmqnhnqhnjbwstiavqerzwvorlthnamznniikjqpuoesycbcnconfevcdkwqrihvmijjvundakrybzzypwkojdbtefldtij...

output:

4

result:

ok single line: '4'

Test #61:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

15494 2
rcv
dkq
hdy
rmj
gde
vor
shn
myj
buz
jkp
qvu
bpo
urm
ywz
wfd
jfe
de
uyk
smi
omc
ift
zhv
lej
rud
uzi
jrg
ufi
ris
nnb
dlo
sbj
kmt
joa
ihr
fyw
ssr
jyz
ysx
isk
gnm
qyz
rmi
gcn
vck
hre
jsp
usr
opm
wld
zpv
kak
wxt
hea
cxl
jsx
ldz
wcj
rha
gyz
yis
thr
knf
oha
tum
uln
bob
qtd
jor
ruk
six
fbt
xfu
tqr
k...

output:

14817

result:

ok single line: '14817'

Test #62:

score: 0
Accepted
time: 0ms
memory: 5984kb

input:

14659 1
szp
zzz
pdw
lnq
ofx
gij
yey
eos
moq
brv
ewu
cbw
dta
fdm
miy
qnm
rrm
bmd
ews
jsy
qao
xti
xaw
ojk
bzw
vlq
hol
mjs
pqm
xve
zbm
ovi
fsw
xhr
rkn
hpj
cme
smz
pbk
kiw
tvf
nkc
atn
qrs
cfz
tia
wzb
bf
fga
qun
sza
xjh
yzi
wws
urz
rsw
jas
wht
nmj
gcf
rod
ajn
mys
ygg
rip
pke
ddu
frk
fcl
br
qei
dak
trs
hw...

output:

14659

result:

ok single line: '14659'

Test #63:

score: 0
Accepted
time: 2ms
memory: 4012kb

input:

15250 1
ezn
nih
xoe
yhi
hxu
vpn
tvy
prp
vg
ffl
gxp
zzi
gml
rbz
ynu
vve
fyh
sgb
vai
cks
ndn
vuf
nfy
qxm
evf
muf
rlw
tvl
afp
znc
boh
jps
pjg
drs
tgl
pax
eu
oxg
dqq
xaz
ncs
tdp
ewa
kmn
bkw
llm
lvq
kjj
iyy
bgs
iux
dvy
wkl
dzk
fra
yai
bgi
jjg
tv
opw
jnf
wvm
uvg
har
vht
srr
mbc
mqa
dgx
wje
raz
vie
amz
ap
...

output:

15250

result:

ok single line: '15250'

Test #64:

score: 0
Accepted
time: 7ms
memory: 9240kb

input:

54413 2
eelv
lcbh
nrnk
icnk
mvbb
tvn
cyvj
ffpe
zvzk
lpc
vblt
hels
bhld
vkye
wvcr
mzlz
viwi
iug
hfu
jycj
pgo
nwrz
assq
gyza
aspv
lnds
gmsl
loj
aaci
ooej
iyk
zbgo
onn
cde
mjb
uati
sgxx
wbi
dffu
gqfw
paqp
qrl
ffaa
hfss
sjwr
zqmz
uqda
amf
ios
umrt
grsp
ogfr
vlsm
ger
lpid
broc
kxa
toma
hfyr
lfim
nrcf
fww...

output:

38449

result:

ok single line: '38449'

Test #65:

score: 0
Accepted
time: 11ms
memory: 10936kb

input:

79657 1
nlxf
olmz
bheo
lkvh
swhn
mqp
apw
lix
scz
kwsm
popm
vgf
hrr
csjs
grpm
rxu
itvt
qxfr
lgra
txla
kijj
nvcz
wcld
yzjp
crfj
xidl
srux
rdws
prot
uqpa
hbtt
nrpc
mbyo
jrfr
kncc
zfww
wzpn
dwi
gqce
rnrd
ylpv
gao
mwfm
ypzt
qzs
qcsj
onqb
msbo
ipcq
tfox
fhrr
hnnd
lmav
zzl
ytyq
lygu
hyqi
xvav
nihn
csf
jbvo...

output:

79657

result:

ok single line: '79657'

Test #66:

score: 0
Accepted
time: 19ms
memory: 16364kb

input:

71696 2
fxdrw
jnb
knr
ili
rzgs
cctn
fkcj
buogv
ugecs
cpmwl
soyru
cxzk
xqfly
xhsb
dxrtl
lybb
ozhe
xtese
iuyk
elg
wgfeu
stro
lbvr
jslx
tiika
vohl
bvk
tfcx
zvv
cixs
gpft
tpz
tpv
cniz
tyba
yohru
ibkmn
qqw
agotw
jjzz
odot
oywzk
hyi
cgbst
tdsv
etbl
igdlo
vintj
iil
jbtwh
hbfe
nyqng
isnbx
mcwq
kmyvh
cdlsw
m...

output:

52248

result:

ok single line: '52248'

Test #67:

score: 0
Accepted
time: 18ms
memory: 15972kb

input:

71585 1
vac
fzyer
apbf
kzy
tgcg
bvut
fgtxs
ktupq
timdr
yxzi
uzrv
iunsb
aiaz
walis
bbcng
navy
fdbsk
prhoe
hwln
izhah
hgr
hsz
tui
itlad
xqxod
cvsbr
jsrc
epvq
xwmro
gecro
wayn
eysbu
fdyq
iwoe
fudtl
pjw
rfqv
bbctu
kzgc
letm
sazgg
tnrah
gnlcv
lzdr
tyxxf
zfhne
vudpy
gfvrw
rgh
czq
fsznk
ypknp
ndo
ibm
wwxf
...

output:

71585

result:

ok single line: '71585'

Test #68:

score: 0
Accepted
time: 15ms
memory: 16060kb

input:

71730 2
hpql
onx
xxm
gxx
bzrec
ejdhm
yvdqh
ucbi
olbu
joxog
dbnk
mlm
eadzj
tnfr
hublk
yyqz
jdxe
sntcl
pydwe
vhuf
zpuxs
rdzbp
qzgnt
gqcqq
hwtj
umrwt
zadw
jav
ibp
amgao
kxadd
hyzbq
vlup
ipmp
ywnbc
lxczd
clv
siru
caob
dgeyf
fnlkg
ijefw
yngyi
jkvm
dnqcw
txjb
fkyh
mruh
mvmp
poje
vbns
seed
rzlc
cafua
swmof...

output:

52434

result:

ok single line: '52434'

Test #69:

score: 0
Accepted
time: 0ms
memory: 4404kb

input:

297 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

297

result:

ok single line: '297'

Test #70:

score: 0
Accepted
time: 2ms
memory: 4160kb

input:

305 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

305

result:

ok single line: '305'

Test #71:

score: 0
Accepted
time: 2ms
memory: 6128kb

input:

284 3
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

95

result:

ok single line: '95'

Test #72:

score: 0
Accepted
time: 0ms
memory: 6420kb

input:

303 9
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

34

result:

ok single line: '34'

Test #73:

score: 0
Accepted
time: 0ms
memory: 4100kb

input:

310 90
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

4

result:

ok single line: '4'

Test #74:

score: 0
Accepted
time: 2ms
memory: 6132kb

input:

299 979
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #75:

score: 0
Accepted
time: 2ms
memory: 4108kb

input:

311 1646
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #76:

score: 0
Accepted
time: 0ms
memory: 6444kb

input:

313 17076
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #77:

score: 0
Accepted
time: 2ms
memory: 4156kb

input:

319 208084
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #78:

score: 0
Accepted
time: 11ms
memory: 40624kb

input:

2 1
bbqrkoojrltrkdnfgsteefcntjcnsltsbmeptdmfpresjdkajmnjpeknrlosanefsocqjeajbrmngobtpkeabiopogeeticctdltnanjkgmsgqgoosdplqfanqonnbigedmphncmogberelbgpmdqrcbijlajbahpjsoiqdtiapespdjckmsosmnoqmmgqabjkkaasfjrejfatbtrrfreodkbefrjlhcqsaibraorsobqseholltcqbsmbmjdhnmtqaennbngoqajodogqrsodhprknnmiorrhnosnsl...

output:

2

result:

ok single line: '2'

Test #79:

score: 0
Accepted
time: 16ms
memory: 77480kb

input:

1 1
cieabretlogmkbnniripeefakhrchofqmlrgpbqdgjdbjfrgchrllfqqnblhlofanblgfpscrmmqtmjprpapigcbmcllseosteplemmschrbbdefqarelsddsqljqaofpqotbqfndgmoeokmgtjendjlsrrlhmqadkimoqmpftisegtjniadrgtemspljobrppssbtshqdnhpcqihjqcptrtlfaejiihdiedctsambbfajaahhooddadmifmrhatnoedgsodtkbgsihlkaemmbotjdrapqeoebfqckmq...

output:

1

result:

ok single line: '1'

Test #80:

score: 0
Accepted
time: 24ms
memory: 40644kb

input:

2 2
lfjjqqhbltidcoqehjmcsnhadetchkfmschceghcnlgpllgeffmglsffgtpjlarncsbdbpabggnrbpadhkdqgidohdppmckmimcrraijodesjaspfmlserircstmpdmkpfojkfhbpbsnisdbcqrtgaebrnfiisdgsnlleiqidjelqrknidptprqfdcomofgnajenbpgafipsalkbbebdgoaglmgnpoarhqqbcedjpellhpnqraegrhsreedrtjsitngtnklifbelhrogcgkebgorpfmjtiflnbfggoot...

output:

1

result:

ok single line: '1'

Test #81:

score: 0
Accepted
time: 8ms
memory: 28528kb

input:

3 3
cieabretlogmkbnniripeefakhrchofqmlrgpbqdgjdbjfrgchrllfqqnblhlofanblgfpscrmmqtmjprpapigcbmcllseosteplemmschrbbdefqarelsddsqljqaofpqotbqfndgmoeokmgtjendjlsrrlhmqadkimoqmpftisegtjniadrgtemspljobrppssbtshqdnhpcqihjqcptrtlfaejiihdiedctsambbfajaahhooddadmifmrhatnoedgsodtkbgsihlkaemmbotjdrapqeoebfqckmq...

output:

1

result:

ok single line: '1'

Test #82:

score: 0
Accepted
time: 16ms
memory: 77780kb

input:

1 2
okjdaoimgrrhafhnhirektlhojcsnqagmdthfrjlgtkchbgjakmimepkgtnksiriicmaqiqmplciirijnhjornimcomjfbikfbmnliqhkgecstegaqrbsbmflaobqggermbrkqcjikkccqhkmitcootgefdkiqefkksggpjenqndgkjbttjpmonmohgrllrqcpiqmqqoallnkikgamijbpgaiasbmslatkqffcqbjcaaokdgssqonfdmbgcqtganqfjhhkshsoqacimnfagehiajoskiehflfgoscntk...

output:

1

result:

ok single line: '1'

Test #83:

score: 0
Accepted
time: 10ms
memory: 29880kb

input:

3 1
obapjorhfmmjtdshtnjrfcksklechlcapbghdidainbbhbjqsbqrsphkmlpriskdjhjiitcdmpbjeijmcpmpadtoisobqhkpirrfiagojbsfhmpisqmkigfoqqtftmsgqgmpdnmskjrkcmdgprodianimoiskartrsjaqglktgtrkhanhidjttsqhrlmdijbdgsteckogfdqsfhoeheqngitebtjkgcmffmhcafqdhhktoijdpbhhtsiejggfimlskhqakmonhgojmffchikghidpfmpcfgbifajfsad...

output:

3

result:

ok single line: '3'

Test #84:

score: 0
Accepted
time: 10ms
memory: 22124kb

input:

4 2
gqgjjfieemtkscojsdnmcrecthfqojlkriqrtksastprmbcpcknritrgjaainpcdmetnhtqaepsllsfkmigiohaiblclqragpbbhftgsbaogjjsibrtmehtbsohkonlqcijgkodkjdagemadrfksrtdjsbtirdbneemribfgqelgnljbebckohthjnsckjpnebjrlckcemqipalsnghjptfeildflmtglroeetdfesnhtidlspetbloadoamhecjdrknssfreohhgtcdiijepqlirnbqihclkpfhsrbo...

output:

2

result:

ok single line: '2'

Test #85:

score: 0
Accepted
time: 9ms
memory: 28528kb

input:

3 1
lpttsggcjapchpcoljaaldcsnalilenglcqkdcnhmslpdondtcgpmpgsphmbgigsgsjlkhmntbrmnpnaklcsgoocdbrafnqfpcsabidlrfdhttbddkgfcamcpbjpqrqcoaqjlnokpbtkgpcqhgeefdtisgicrtbsgjjjiotqphgaltpeobbbtgenkmrnilpohfroebqmancfejdrgkpaccjherjnlbanrtktfocijpspjenoghnnqordfkagohbkgsddbpieaagkjecqhagcegroirslkcjbpnbfhiij...

output:

3

result:

ok single line: '3'

Test #86:

score: 0
Accepted
time: 11ms
memory: 40528kb

input:

2 1
rmbqndjnregltgfqakccrltlgcjdqcdlnephnaljekgrskbicspjhsgtcgrgotohajqakfigippaabqaknkoaoeqopaaorfltsdpikpanfadniodrllamlcfddtdofbpqnjflcjqdaqooegkroeshqckdgefkolfobrjrjikhdqrglamdmcljgsdpteiajfcrkrmmnitqrdhrhassjhidbeqhdrgdjcesnesngilrisbpfpmokcknsqgejttbecdndqilbinmcihboolqgcljlagsshnhfjbqtelcssm...

output:

2

result:

ok single line: '2'

Test #87:

score: 0
Accepted
time: 19ms
memory: 77564kb

input:

1 1
kgogadoirtftfpefeabclehdhoegcoqsgeeijfpsassehsiegdgemjscrpsdmchmcmfoqoihhrhhpdgifhgkjlaqiiggaotgbeqsdelkamjrhopchffprloemkikbqsrttttdbdlsnkqtqjpofmhgnerpffpcroqidptclmatiiskshbkcitqdsiaehjqnqnfshabgggifbdfcjmsghhsdtnesppahbbchggtfjbptrtltnqbghimratpeqpsnjqjlosnfgkilsokplhposaheamnoipgikpaoqjkqoe...

output:

1

result:

ok single line: '1'

Test #88:

score: 0
Accepted
time: 7ms
memory: 20328kb

input:

5 4
hfnhfbneglrbhfcmlpfrtbrnfkjmrpplanseckcfhseejpgamjejrhmdebfpfparsgcsskbkhntestfcgoosdjmclkoaqeedbmqldceaaspejrpqgsedcmplconiaakbohdfomlctctmkcftjtlsdrasmkigmdjocnpjgnlqmehegcnmtjolabonfjkdqntefhacsnmdplmatggmrierslpskpearqgnlgttrsclnpcnkogeqqfshpgkgltojmltknseltiqphpctinhmifprqmcbnhohconjqrgmohb...

output:

2

result:

ok single line: '2'

Test #89:

score: 0
Accepted
time: 6ms
memory: 28276kb

input:

3 4
qqnacprbobehtipsbgmgdlpkhilqhftikreonghdskaatcbbbmdfnhodkmflohcprtlsgrpgsjnmbhrlbdcjqihccbjlncibqiqcndeqmdappdfaecgbtghrfjroftridpjsclomqtkolqdmcmbcmfqcsfilsppbocmpgkrqiqsmidopqerrjhrhnndqsjnmtqnqpscdaskdjotbipakdirsqhpoqkckjmdtchoamqcjiljehnklkrihlsdnomoroaasbnejrkknssaqhkjfrdalosdfakckjfslmnit...

output:

1

result:

ok single line: '1'

Test #90:

score: 0
Accepted
time: 4ms
memory: 6196kb

input:

32 7
lrormlhldnkohnhoqrthegscbakqgqmhpniplgpferooflmgargmdhangqmglhcnbnfmkbrlqdbimffdqepqhhdrholhsfkomipddnaqermfhiphmgbdkjdqoignbodqjsqkdiroaobjgrdphlbbdtfkbrpngecjtccalqmpfocrpjgekrreifebhiecrbqemaibshohocoonodtdlqnhrclngelgnibrlbafmrrkegjqecptgofckpifibobmkidocslkahoqhbtqoaqknbtlhtijpkqfnbbodrqlf...

output:

9

result:

ok single line: '9'

Test #91:

score: 0
Accepted
time: 0ms
memory: 4536kb

input:

88 8
anscjbirolnhdafkbjdjedrlhjnlontmabskftplqelhpptceetkgqkfahqqgonpttlasfnmckfgqkafggjphbkrascnsisntnpmslqtsegetoracekpkjrjjeetbdlhtpqgfeeibbiacrisehmibdonppqnoelaidfjedrrmmlmgrjjakmgbgmrillpnjfecktkaqhdmnghtengcpcamislprogtfosditclbbtrjioprtdkpeqccdlnaqjtjnhstmjoohsaorcprrpltcbgratjkqleppmdkobqdf...

output:

22

result:

ok single line: '22'

Test #92:

score: 0
Accepted
time: 3ms
memory: 4452kb

input:

100 8
dapirqhbtipikottssejjdetflhhkincokrfmcplpapmrcqiplbshcehocpibqlgtmckllpgttgfdmkfcrfsoiqsjsdtlgjinmahhbdnqmaientqhcjkactpfddbpbaqifsqlelocpaakkpatfcfislanjitpdlrrnteepjjlpnadipsnaerrmcoqbmkiltekhaiaimggdgagdmetpmtjhgbanjapkcelhpcnqllmrfbnonpmosbjpspqfjqhtjligclrmkqcokjbohrbtpckeddrdmjojjghdeiib...

output:

25

result:

ok single line: '25'

Test #93:

score: 0
Accepted
time: 3ms
memory: 6200kb

input:

602 9
cacicfmladtsnhgjiaktepbkshrichgmhegbccfjmsnkfkhnqjplnelonjdeclnistcasrnggbaaoabpfmrmatcdfkqsgrfqpdggntlkqeiptpdigsssikstfcqqlqgtonrhcffbbgahiorbrasbhihtkictcskgcijnooemlrlpnnfnnjtnafmqhiqqrndthreirecfralcgofeljlipiktrgcbnbrrpkqrndahfkmnclqknbcjpomldifnettgeqtjnodtjqlbrqigkcqlagimpjpcojkrkelhtt...

output:

121

result:

ok single line: '121'

Test #94:

score: 0
Accepted
time: 2ms
memory: 4172kb

input:

408 8
dfeiingdhrprklkslfjfbgnpcmkklejjmqbmstihsmhjlehhpsdaofmkgaokodmossqlihfckeijfeoemasheqantkdfmorhijfhqaqoefffraafhpgqkkcllqfdhgshknaloghlbblhtnictqjmhssgkomomjlmcqtsbjpdidsqstllafaaklsaeljmthlroohpdgcojlekjtdhrcksmkstacecfnnstsrgtlakkagcbjsoplhpitmkcqnkritooqnhmiqltrbmbqsobifaddbbsoftkhtqijganj...

output:

88

result:

ok single line: '88'

Test #95:

score: 0
Accepted
time: 3ms
memory: 6492kb

input:

911 2
rktoblponatjhsrjodjdcdgahnaskacgleggtbcsbqbjcarjdnmankgfnlhndipnkbjiloadfmgsdibckkmdkberpimbkjngslshmnlkpgkaadhsigilltsqaetqckepkoacnhqbtddtcgmcissslrfiifmcihhihtioqpcimcpitipofjqihnlniggmedmposoknfhehtbigljmrpgbfmfljeetteroscrgqrjcejrbjsfqfffdnteoiancjjnobgffbfejbdngnsitkbtgllkpsdkkpqdagpqffq...

output:

619

result:

ok single line: '619'

Test #96:

score: 0
Accepted
time: 3ms
memory: 4080kb

input:

349 300000
feronnileamlmphalasnlioilkaelktlaghierlqihjjdrmfpkqasrtcioqfiqmettkchnqdtrlcgqprgfdmrajkpmanaefncjhkndlbbcndinnspehjqkdjrbmqeskghngcqhjtqrgdcnesqfmdliadsbnjslpasiklffrrplqbsplenhribpdpcmhtjmraitndffjfpahoabstbesgbblsodafemlqlgagnbohaafqqptkjpaposdktohifkrlrojgslabfdkjgggslphanneqbgqlhpfdb...

output:

1

result:

ok single line: '1'