QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86425 | #5368. 异世界的文章分割者 | xiaoyaowudi | 100 ✓ | 2354ms | 21036kb | C++14 | 2.4kb | 2023-03-09 20:19:03 | 2023-03-09 20:19:07 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
constexpr int N(5e4+10),iinf(1e9);
using ll=long long;
constexpr ll inf(2e18);
namespace T
{
int mxlen[N<<1],link[N<<1],trans[N<<1][26],sz,lst,n,pos[N<<1],mx[N<<1],mn[N<<1],mnlen[N<<1];
std::vector<int> es[N<<1];
void init()
{
std::memset(pos+1,0,sizeof(int)*sz);
std::memset(mxlen+1,0,sizeof(int)*sz);
std::memset(link+1,0,sizeof(int)*sz);
std::memset(trans+1,0,sizeof(trans[0])*sz);
sz=lst=1;n=0;
}
void extend(int id)
{
int cur(++sz);pos[cur]=++n;int p(lst);mxlen[cur]=mxlen[lst]+1;
for(;p && !trans[p][id];p=link[p]) trans[p][id]=cur;
if(!p) link[cur]=1;
else
{
int q(trans[p][id]);
if(mxlen[q]==mxlen[p]+1) link[cur]=q;
else
{
int c(++sz);mxlen[c]=mxlen[p]+1;
std::memcpy(trans[c],trans[q],sizeof(trans[0]));
for(;p && trans[p][id]==q;p=link[p]) trans[p][id]=c;
link[c]=link[q];link[q]=link[cur]=c;
}
}
lst=cur;
}
void dfs(int u)
{
if(pos[u]) mn[u]=mx[u]=pos[u];
else mn[u]=iinf,mx[u]=0;
for(int v:es[u]) dfs(v),mn[u]=std::min(mn[u],mn[v]),mx[u]=std::max(mx[u],mx[v]);
}
ll calc()
{
for(int i(1);i<=sz;++i) es[i].clear();
for(int i(2);i<=sz;++i) es[link[i]].emplace_back(i),mnlen[i]=mxlen[link[i]]+1;
dfs(1);
static int b[N];
for(int i(1);i<=n+1;++i) b[i]=0;
for(int i(2);i<=sz;++i)
{
int l(mnlen[i]),r(mxlen[i]),j(mn[i]),k(mx[i]);
if(k-j<l) continue;r=std::min(r,k-j);
b[j]+=r-l+1;b[j+1]-=(r-l+1);b[k-r+1]-=1;b[k-l+2]+=1;
}
ll ans(0),cur(0),d(0);
for(int i(1);i<n;++i)
{
d+=b[i];
cur+=d;
ans+=cur*cur;
ans=std::min(ans,inf);
}
return ans;
}
}
ll calc(char *s,int l,int r)
{
T::init();
for(int i(l);i<=r;++i) T::extend(s[i]-'a');
return T::calc();
}
bool check(ll mid,int k,char *s,int n)
{
int c(0);
for(int l(1),r;l<=n;l=r+1)
{
++c;if(c>k) return false;
int j;
for(j=1;l+(1<<j)-1<=n;++j)
{
if(calc(s,l,l+(1<<j)-1)>mid) break;
}
--j;r=l+(1<<j)-1;
for(int t(j-1);t>=0;--t) if(r+(1<<t)<=n && calc(s,l,r+(1<<t))<=mid)
{
r+=(1<<t);
}
}
return true;
}
int main()
{
static char s[N];int n,k;
std::ios::sync_with_stdio(false);std::cin.tie(nullptr);
std::cin>>n>>k>>(s+1);
ll l(0),r(1e18),mid,ans;
while(l<=r)
{
mid=(l+r)>>1;
if(check(mid,k,s,n)) r=mid-1,ans=mid;
else l=mid+1;
}
std::cout<<ans<<std::endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 3ms
memory: 8224kb
input:
10 3 aaaaaaaaaa
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 3ms
memory: 6872kb
input:
10 1 abbbaabbba
output:
289
result:
ok single line: '289'
Test #3:
score: 0
Accepted
time: 3ms
memory: 6288kb
input:
10 2 cacabbcbca
output:
11
result:
ok single line: '11'
Test #4:
score: 0
Accepted
time: 4ms
memory: 7504kb
input:
10 4 aabbccddaa
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 3ms
memory: 7024kb
input:
10 4 ababbbabab
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 1ms
memory: 6492kb
input:
10 2 ababbaaaba
output:
12
result:
ok single line: '12'
Test #7:
score: 0
Accepted
time: 4ms
memory: 7068kb
input:
10 1 baabaababa
output:
156
result:
ok single line: '156'
Test #8:
score: 0
Accepted
time: 3ms
memory: 6848kb
input:
10 10 hbjebnidnq
output:
0
result:
ok single line: '0'
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #9:
score: 10
Accepted
time: 3ms
memory: 6332kb
input:
50 10 aababaaabaabaaabababaaaaaabbbababbaababaaaabababba
output:
17
result:
ok single line: '17'
Test #10:
score: 0
Accepted
time: 4ms
memory: 7664kb
input:
50 5 bbbaabbbbbaabaababbbbbbaaaaababbbaaabaaaaaabbabaab
output:
91
result:
ok single line: '91'
Test #11:
score: 0
Accepted
time: 2ms
memory: 6664kb
input:
50 5 adbabadbabadbabadbabadbabadbabadbabadbabadbabadbab
output:
412
result:
ok single line: '412'
Test #12:
score: 0
Accepted
time: 0ms
memory: 5748kb
input:
50 3 caaabcaaabcaaabcaaabcaaabcaaabcaaabcaaabcaaabcaaab
output:
3222
result:
ok single line: '3222'
Test #13:
score: 0
Accepted
time: 3ms
memory: 5836kb
input:
50 1 cadabcadabcadcadabcadabcadcadabcadcadabcadabcadcad
output:
407986
result:
ok single line: '407986'
Test #14:
score: 0
Accepted
time: 1ms
memory: 5884kb
input:
50 15 bbbbbbabaabaaaabaaabbaababbaaabababbbbaabaababaaba
output:
3
result:
ok single line: '3'
Test #15:
score: 0
Accepted
time: 2ms
memory: 6728kb
input:
50 20 baaaaaaaabbabbababbaaaabbabaabbababbbabbbabaaabaaa
output:
2
result:
ok single line: '2'
Test #16:
score: 0
Accepted
time: 2ms
memory: 7196kb
input:
50 6 ababbbbaaaaabbbabaabaaabaaabababababbaaaababbbbbab
output:
65
result:
ok single line: '65'
Test #17:
score: 0
Accepted
time: 3ms
memory: 7664kb
input:
50 1 aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa
output:
129389
result:
ok single line: '129389'
Test #18:
score: 0
Accepted
time: 1ms
memory: 7204kb
input:
50 1 acbcaabcababaacbbacaabcbacccbbaacaccbabccacaccaabb
output:
16446
result:
ok single line: '16446'
Test #19:
score: 0
Accepted
time: 3ms
memory: 6408kb
input:
50 14 ccaccaccaccaccaccaccaccaccaccaccaccaccaccaccaccacc
output:
6
result:
ok single line: '6'
Test #20:
score: 0
Accepted
time: 3ms
memory: 6028kb
input:
50 24 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
output:
2
result:
ok single line: '2'
Test #21:
score: 0
Accepted
time: 1ms
memory: 6392kb
input:
50 50 txcopptgjrvkgzdvaxgrhwgnkjfbspyytzkbirczhcrctddsfj
output:
0
result:
ok single line: '0'
Subtask #3:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #22:
score: 20
Accepted
time: 2ms
memory: 7388kb
input:
200 1 cabaababbabbbcabcbcaacbccaabcacbccaabbccccbcabbcacbbcbacbccaabbbbcbcabbacabbacccbbbbbacccabcccaaacbcbaaaccabbbabcaabbbababcabccbccbaaabbbcbccbbcacbbabbaabcacbcaccccccaaaccabbaaabbbcbbccbcabbbcabcccabb
output:
2192936
result:
ok single line: '2192936'
Test #23:
score: 0
Accepted
time: 3ms
memory: 5928kb
input:
200 2 cbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaa
output:
1196175
result:
ok single line: '1196175'
Test #24:
score: 0
Accepted
time: 3ms
memory: 6380kb
input:
200 3 acabacbacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacac
output:
1550907
result:
ok single line: '1550907'
Test #25:
score: 0
Accepted
time: 5ms
memory: 6628kb
input:
200 7 hefdaadcdgfecghbgcbggfgdfchchgbdfafghahacgbbcebfchadbcechdacacccahggadbdacbggadbgceacgeedfafbhhfhaacdccefddbfaffcdggabhhcghcbfbedddeheaeaabdahhbhcefeededbfdafghdahcfbfbcbbdgccffhaeggcdhdcghghfaaefechd
output:
1134
result:
ok single line: '1134'
Test #26:
score: 0
Accepted
time: 5ms
memory: 6144kb
input:
200 11 lmmeigmkegfbcmhfedchmeckbnbgjlfljahjleeldlnkdlnkngaeiiblangdlkdfjchalckfhfcjgljlelebhfacafkjknknjjfklnhcnlgkkjmhfafmhehgehmejajabgaikfnclihbkmeckghfljgfmajflilgcimamgljlhjkfhgjcbcddfjlnchcgedmghdlfaib
output:
155
result:
ok single line: '155'
Test #27:
score: 0
Accepted
time: 5ms
memory: 7524kb
input:
200 19 cdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbac
output:
133
result:
ok single line: '133'
Test #28:
score: 0
Accepted
time: 2ms
memory: 6456kb
input:
200 16 acdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdb
output:
481
result:
ok single line: '481'
Test #29:
score: 0
Accepted
time: 5ms
memory: 6412kb
input:
200 25 abacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacda
output:
99
result:
ok single line: '99'
Test #30:
score: 0
Accepted
time: 2ms
memory: 6880kb
input:
200 25 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadkgmivxnitlfmciurqeqnqghxveqrxidxbmzlpdveuucarjwdqyiiaegadulttqmkzinvxalbvnccchfvjechxnufmcmofrdkesmkjeiobfzwbppknslhtxoranwbjnxggudgjmjrigintzxkusvvaqwhuwvoyiz
output:
6
result:
ok single line: '6'
Test #31:
score: 0
Accepted
time: 6ms
memory: 7232kb
input:
200 37 aaaaaaaaaaaaabdecdebedebaaaaaaaaaaaaaaaacebcbcecaebeaaaaaaaaaaaaaebcddecebbebaaaaaaaaaaaaaaeadaaecdadbaeaaaaaaaaaaaaaccbabdbbeedaeaaaaaaaaaaaaadbddbebeddcbeaaaaaaaaaaaaaaceeedcecdadbaaaaaaaaaaaaaaaaaa
output:
10
result:
ok single line: '10'
Test #32:
score: 0
Accepted
time: 5ms
memory: 6136kb
input:
200 64 bbabbbaaaabababaabbaaaabbabbbaabbaababababbbaabbbbbbbbbabbbbabaababbbbabbbabbbaabbbbbaabaabbbbbbababbbabbaaaababbbbabbbaaaaaaabbabbaabaabaabbaaabbaaaaaabaabbbbaaaaabbababbaabaabbbbbabbbbababbbbaaabaab
output:
2
result:
ok single line: '2'
Test #33:
score: 0
Accepted
time: 4ms
memory: 6260kb
input:
200 49 abbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbab
output:
10
result:
ok single line: '10'
Test #34:
score: 0
Accepted
time: 5ms
memory: 6268kb
input:
200 57 zbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbz
output:
3
result:
ok single line: '3'
Test #35:
score: 0
Accepted
time: 3ms
memory: 6124kb
input:
200 44 aaaaaaacdaadaaaaaaabdbbaaaaaaaaaacbdaaaaaadccdcbaaaaaabdcdadaaaaaaccdabbaaaaaadcbaadaaaaaacdcdbaaaaaaabbcbdbaaaaaaabacbbaaaaaabcbccdaaaaaadbaabdaaaaaadaacddaaaaaaadcdbcaaaaaabbcdcaadbbdccdacdbcaccdbbd
output:
6
result:
ok single line: '6'
Subtask #4:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #36:
score: 20
Accepted
time: 8ms
memory: 8124kb
input:
1000 153 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
28
result:
ok single line: '28'
Test #37:
score: 0
Accepted
time: 22ms
memory: 7708kb
input:
1000 79 babacbbcacbbccccababbacbacacbbcabcabbaaabccbacbaacccaaaaabbcabaabcaaabccccbbaabbcaccaaacccbaaacaacccaccababaacbcbbacbcbbbcccbbcbaaababbcbacaacaccbcacaaccbbbcaabcaababbcbbabbccaccbccabaacbcacbbccbbcbaaccbcaacccacccccabbbabccacbbbbcaabccccacababacaccacbcccbcccbaccabaacbaccabbcbbacaabcbcacccaac...
output:
200
result:
ok single line: '200'
Test #38:
score: 0
Accepted
time: 16ms
memory: 7348kb
input:
1000 6 ahcfaddebbbccheeffbfdbbbdcjhdefhcibhgjbgeaigaaifcbdfbjdjiddicbhagggaaaajiejjjfdabcjjjceieaijacjbaecifacgdajcigfababaddecfehdhfbfjhdahchahiiiafaibdbbdegeachfdicciaegdcagaahgdgebdhbdejajafajjjfdjfjdijjgahjdjjjifeejjbachjaiacgjfhccebjgddjehiecibjfheicgihfdabhbdiijbcdgffaedcejecciddahjajdfjiddhgc...
output:
237763
result:
ok single line: '237763'
Test #39:
score: 0
Accepted
time: 20ms
memory: 6648kb
input:
1000 79 cfbdcgcdcdgabebecbbgcebcgefcbdageefffaddafegeabdagdaaabeaedgabgedafdegdggbedcceafgegbceceebaaadbccgadebeaeebcaggdbdgefeaeegafgbaeegaadbcaeddceecacbecdgfaefaeagdbaadbdfceedgdabfbaadcffgbedfgbbdddbcgdfccaeabbgabdfgefcefbaadefcfagebegfafbabfcbaagbedacfgffefadcdecbabbcfaegcgcddbagceaaaabcfacgfbe...
output:
91
result:
ok single line: '91'
Test #40:
score: 0
Accepted
time: 12ms
memory: 6284kb
input:
1000 3 htspasbnfsqdnsppbkaaprldgjpfaikdjcaojaejdtipsrkrfddlkepkqbjprsejnpcqigqjkmpqfhbbglccmtrrngoopfscopnocqkfesphqnteofsinkqqopnknbkejodkpnmjobgcisimpsgnqqidtfsdjakntlkgtgnnaietrijhgksrsnohilbrrtcpndciksonfptfkljhhisihcngqsdmgreakrrgmgnspabhfmegnmhtlhkrfnliipssjcbdikfgqmjtaltootaaopdrfrfrdaelnbrdd...
output:
1022595
result:
ok single line: '1022595'
Test #41:
score: 0
Accepted
time: 13ms
memory: 6780kb
input:
1000 14 jmgovzbodqoznwcmegtwxcunytkvnnoqixxjgbspvoochcctbmgfcofmdctzmpxwqwztunedfpvrdbbgujrmowvbahioiwnewuidqkajpxdkwckpmmbrkbrebgiqdktjgeaktrcgcaduslvxlpqofscjzmjmjyyzpvogthoglxsdvqpvcccfljopkcudctgxjovrppnbyzairtebpggtheutanrfalcsakvcreyxxchzalfaybwptnbulyteeuapgoscpzvigwetrjhtzxtgzhehhknztxhcvrbw...
output:
11558
result:
ok single line: '11558'
Test #42:
score: 0
Accepted
time: 5ms
memory: 6544kb
input:
1000 102 bacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaab...
output:
384
result:
ok single line: '384'
Test #43:
score: 0
Accepted
time: 15ms
memory: 7328kb
input:
1000 11 dfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidab...
output:
15796914
result:
ok single line: '15796914'
Test #44:
score: 0
Accepted
time: 10ms
memory: 5912kb
input:
1000 3 cmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhd...
output:
6797306034
result:
ok single line: '6797306034'
Test #45:
score: 0
Accepted
time: 12ms
memory: 7512kb
input:
1000 1 deebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcab...
output:
13523081623
result:
ok single line: '13523081623'
Test #46:
score: 0
Accepted
time: 8ms
memory: 6740kb
input:
1000 176 ddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddc...
output:
15
result:
ok single line: '15'
Test #47:
score: 0
Accepted
time: 7ms
memory: 5984kb
input:
1000 176 dcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbd...
output:
26
result:
ok single line: '26'
Test #48:
score: 0
Accepted
time: 13ms
memory: 7152kb
input:
1000 1 bbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbaba...
output:
674957710334
result:
ok single line: '674957710334'
Test #49:
score: 0
Accepted
time: 18ms
memory: 7252kb
input:
1000 27 aacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebe...
output:
97930
result:
ok single line: '97930'
Test #50:
score: 0
Accepted
time: 11ms
memory: 6052kb
input:
1000 92 agddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghj...
output:
91
result:
ok single line: '91'
Test #51:
score: 0
Accepted
time: 16ms
memory: 7544kb
input:
1000 229 acabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaa...
output:
6
result:
ok single line: '6'
Test #52:
score: 0
Accepted
time: 8ms
memory: 5992kb
input:
1000 387 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1
result:
ok single line: '1'
Test #53:
score: 0
Accepted
time: 15ms
memory: 7152kb
input:
1000 79 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaautinovsqokcxceilfvzjuysmgbiyekhrjqvuhhncnpwdtvsyztzgtalquqtzfcvkwymtgamyvbgfzwdauxdetdjumnyi...
output:
107
result:
ok single line: '107'
Test #54:
score: 0
Accepted
time: 14ms
memory: 5932kb
input:
1000 15 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaeykkmvfmjxnnkseynhnyfbqpwwixbaaaaaaaaaaaaaaaaaaaaaaaaaaaaarpatbemszmhqxaxnyvkrdyqhbghuuaaaaaaaaaaaaaaaaaaaaaaaaaaaaayslipjklioorocacxthuhpczyttxgaaaaaaaaaaaaaaaaaaaaaaaaaaaaahakpigwtewvfeumzjluchidvlsfobaaaaaaaaaaaaaaaaaaaaaaaaaaaaazwzvxvonganwxwbacknxoaozsirfuaa...
output:
11461
result:
ok single line: '11461'
Test #55:
score: 0
Accepted
time: 13ms
memory: 6040kb
input:
1000 1000 lgugapptmavvpeohxdkunrtpzidgaokzvstjjgksmlbkmqsuymbcdjrwgeigyrxbepzxpjvqmdsotqfpkpxlhqimhsdmplvvnarlejkguqqdvuxexwnqmfvtbilpszuonxvkmqfejhjkhvswijpbjacbjutfrkkmzdryibkpzpzdkcdavvqyygpvzxtmpkqzapdreghjxogcvigztzpeecembjpvifgmnvreswaestowqvolqgwpvkvtgtiimgvhjegzuwdjdfhlectopiinmvkyckopyavyyv...
output:
0
result:
ok single line: '0'
Subtask #5:
score: 40
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #56:
score: 40
Accepted
time: 2354ms
memory: 16332kb
input:
50000 1 eaadcfedcbcceccfccdbbeccbcaeaaeffbbbecedddfacfdeaadbbebdcbaafcefedddbfdfbcdfbccbdcdcbccbebcbddfcdaacfefffbafcdfefabbecbcacdfcabbebedacdbcdfebbccfeecddcfbdfbebffafdbaeddcbbecfdbfaecbeeffcdfbceefeddfdadfadfadfeafaeddbccabebeaccadbfdfbedededecccbcdcafddefaefccbfbcdaeedfeaabdceafeaabcdabbceddecc...
output:
10929072780271
result:
ok single line: '10929072780271'
Test #57:
score: 0
Accepted
time: 1717ms
memory: 14968kb
input:
50000 1 gkhkjgfdaleeedqndpdmloccjpmfjccgljhflhdlponlqkmdeeipldediiocnmbqpemqqdpgjpmhccbalagqpndfkbpdmoegqqmogcbnnhhlbkgkaenqnoqelfoipclpadgppqmglmohdmeofgplpgclpkpgkpfggnkedcjoqfpbfffnqbmiaahhnkbacqgndchjkgknmgnhgbajnaahaeieqbcjjbhkqablmannnhhkcnlikjhikdjpeknpjgccbopfcgbaldjkckhdaopiifpojlomacnjkgod...
output:
3919799366097
result:
ok single line: '3919799366097'
Test #58:
score: 0
Accepted
time: 2171ms
memory: 16164kb
input:
50000 2 dywnjsdsqucmugwjznrryntujlauuycoadwemeamjhdfttkusnlddamdphpocuuyybnsjhqbopghiofjytxxkqeswozivewcmqhdaokbkjgkqfcccvcgjzoazunxmborqibfnyyhsrfvbldesvurxywquncvftcuazwzgdugsdtjlyzbxzeyzmqlvfjthnxujrcidjmvpwtcxjyiexqwqsqnrjxzwklygwhsshsxgxswyneojeualdftvjhwpmqbuwbtgidwfuvgqwcurpnrkfskoqkdzkbvfukc...
output:
445287879854
result:
ok single line: '445287879854'
Test #59:
score: 0
Accepted
time: 927ms
memory: 14608kb
input:
50000 1 dcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddc...
output:
260329176674704
result:
ok single line: '260329176674704'
Test #60:
score: 0
Accepted
time: 1360ms
memory: 14104kb
input:
50000 2 bdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceff...
output:
219715009632838
result:
ok single line: '219715009632838'
Test #61:
score: 0
Accepted
time: 1585ms
memory: 13872kb
input:
50000 3 nihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopn...
output:
582704337052667
result:
ok single line: '582704337052667'
Test #62:
score: 0
Accepted
time: 2056ms
memory: 14080kb
input:
50000 2 bpzeonrxhvmmwwkyfurffcakwgajxuqxdvfausbbokvavccmtoxsfswyyzdgklnfstlmzngwxdslkzxekqyuqjjhxudzbfectlxcxoeiwflxhkyvgbgmwsczpcguwobmfspabeutdfwqtsnryzhhtmlhpoaweuillzrepgogirppxbkktnbljrylwrpltsbinaekcvjlqgizbpzeonrxhvmmwwkyfurffcakwgajxuqxdvfausbbokvavccmtoxsfswyyzdgklnfstlmzngwxdslkzxekqyuqjjh...
output:
52863724029762619
result:
ok single line: '52863724029762619'
Test #63:
score: 0
Accepted
time: 1835ms
memory: 16300kb
input:
50000 14 dgeliicbdaaijggngndehgbnhiaajjkaalenhaceemblmildbbmlkngcekjhbcblbckiianfcihfndiijbjdhdkgbifdbegfnmghaakdgajbkehnkhcnfjfalcjkcemnkhdkkjmdamdmajgehnkkdnbedklndgfkagdaaljekjhfmnaedllnjmndlhifmnllkhebmjlhkfgjijkcjffbenemhjljmbgbjhngnjeafjlefjdfkbjefkkajfjidckbegeieifcfeghmjhmejhlclfihakkimkhnjn...
output:
1814156853
result:
ok single line: '1814156853'
Test #64:
score: 0
Accepted
time: 1559ms
memory: 15768kb
input:
50000 27 omokibdejmnllgbdqaaclogbqjdlmkplnfcmankchcboeqkjonlbbqihjiopffaejqlapfjjdpjfpqnlgdhniqpmcqmbnpgmfclanifoqneqnhnbeaoohqboqappchppnpbjompkbcnjqijmgnkddccoogaoablqlnfqecnqileeioabgpaemomojoghhboqaajgajdjjiiiomdhoijmgnpeqbmiilaqclhaonnmeojhmhnilqbqhpfjcklacldqbknomebghgeoqmjhqcnpeifiillbhhdeqqb...
output:
214605170
result:
ok single line: '214605170'
Test #65:
score: 0
Accepted
time: 2091ms
memory: 17476kb
input:
50000 62 beacebecdedbeddedededdecdadadcbeaedbbacbcdceadabbecaabecbcbaacddeeabdcebdaceaaaabacedabbedebeaacbeadadeadeeaccdeecbeadadebdeeaadcccceaaedbcceadebdeeeaddeddbcdecdaeacccdccecbeaaebcaedaaaccbbddbbceecbcdccdeddeccbbeacceaceabeeabeddeaababbbdbaebacdbdddeadecdddebcadeeaaddcdcdadceeabdcaccaeeecbed...
output:
56128859
result:
ok single line: '56128859'
Test #66:
score: 0
Accepted
time: 920ms
memory: 13964kb
input:
50000 79 bmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejgg...
output:
19534901514
result:
ok single line: '19534901514'
Test #67:
score: 0
Accepted
time: 1037ms
memory: 14092kb
input:
50000 96 bqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpke...
output:
42964961476
result:
ok single line: '42964961476'
Test #68:
score: 0
Accepted
time: 1367ms
memory: 10036kb
input:
50000 88 cabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacab...
output:
38369677770
result:
ok single line: '38369677770'
Test #69:
score: 0
Accepted
time: 1141ms
memory: 14688kb
input:
50000 103 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
4645311
result:
ok single line: '4645311'
Test #70:
score: 0
Accepted
time: 1172ms
memory: 16784kb
input:
50000 115 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
3275390
result:
ok single line: '3275390'
Test #71:
score: 0
Accepted
time: 1665ms
memory: 16608kb
input:
50000 334 bgadgbafgghbjhdfddjcbfgcgbhaecajjhhbgbadiicbcdccjjhbcjdihidehdbgfhhjediaahecjdjehifbabhbcjfdbghfgigegchhdbhdgdchgjgcdfbjbcaiigfhgbjfaagjjgiihaiaeajjhhdfifhciebidabiefifhedcajfcbhdbceaggjaaedadhjhgigibbdhaficfcciaaefcbcdceddhihiiffadedgcdhdigijdebhchejabfgahehggafhacbhijbadhfceihfeeejfhghci...
output:
160984
result:
ok single line: '160984'
Test #72:
score: 0
Accepted
time: 1361ms
memory: 16256kb
input:
50000 453 rgyzchgqoskbomrmkyapwmpvgaynsjjvfmirllorsrgmlvwgzeiaorzhzkqyvldplrwjshxmtkwxfprbwxtxejpbbnignbijtafznifvdaitywznmvbdkpohisyabydkvsigplhuafuswlevunwladpvuqdcqxxkekyytgithubwhmxqxmmxfkmtctekslcpzbatzkdksognowpiizhfzzifwkjixndpskojfxyczmoroefnvizjsjfnnotkhtfyjwgmgoqtjtkyfbdvsjotnxsefqpahkaugr...
output:
38614
result:
ok single line: '38614'
Test #73:
score: 0
Accepted
time: 849ms
memory: 13920kb
input:
50000 626 anbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpi...
output:
8946471
result:
ok single line: '8946471'
Test #74:
score: 0
Accepted
time: 789ms
memory: 13980kb
input:
50000 875 adgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjagga...
output:
1508468
result:
ok single line: '1508468'
Test #75:
score: 0
Accepted
time: 1206ms
memory: 9888kb
input:
50000 710 acadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccac...
output:
1895757
result:
ok single line: '1895757'
Test #76:
score: 0
Accepted
time: 1911ms
memory: 17516kb
input:
50000 1335 ebadcedecceabbdacddbcbbdbbccdbdcaaddbaeecbecabcabdcbdcbcdbdcccabbbaecdbcaeaaeadbabacdbaecccecedabdeaadbaaeeaedacaecebabecbbccebeeceecbbecbacacaebbccbecbcbddedadcabaaeeecbabadceeeeccaedbeaeddaecabcddbeaabcdeedcacecdebddbbbbbbdbbcbebccadbdacdcdbceeadbdeadcbaadaeecebbecdaaaebbbcbadaebbdcdabe...
output:
4248
result:
ok single line: '4248'
Test #77:
score: 0
Accepted
time: 1623ms
memory: 16728kb
input:
50000 3526 ghfjgjajgiafjjgjfgicedjeaiicceighggccddcegfgcagbffeagjcfjbbdehajdahejcedgiifacbbdhhbdacgbjggheihahgabjjaajdeehdgigjeggfedhfcehafbeibeebefjgaijahgibiebbedjcajahdhehgcdceafhfeafbcgajhffeadabfhdcebjcbcchjfhafajhhjdigechhfbhbgbdbgdcdjcaddfiedicbjigiiejafdhdfbdabfhcbaahadaijgbgdjgjdbjihfehgbhi...
output:
88
result:
ok single line: '88'
Test #78:
score: 0
Accepted
time: 716ms
memory: 14164kb
input:
50000 3526 dfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjad...
output:
303
result:
ok single line: '303'
Test #79:
score: 0
Accepted
time: 1035ms
memory: 10160kb
input:
50000 4428 bcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbab...
output:
330
result:
ok single line: '330'
Test #80:
score: 0
Accepted
time: 676ms
memory: 14652kb
input:
50000 5074 abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa...
output:
269
result:
ok single line: '269'
Test #81:
score: 0
Accepted
time: 2038ms
memory: 21036kb
input:
50000 26013 abaaabbabbbbbabaaaabbababaaaaaaabababbbbababbabbabaabbaaaaaabbabbbabaaabbababbbaabaaaaaaababbababbbaaabababbbbabaaabaaabaabaababbaaaaaaaaababbbbaabaabababbbbbbaaaabaaaabaaabbbaaaababbaaabbaabaaabbbaaaabaaabbbaabbbabbaaabababaaaaabbabbaaaabbaaabbbbbabbabaaaababbbaaaabbbaabbbaabbbbabbaabaa...
output:
1
result:
ok single line: '1'