QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748872 | #5368. 异世界的文章分割者 | Kevin5307 | 100 ✓ | 5381ms | 20844kb | C++23 | 2.9kb | 2024-11-14 21:47:12 | 2024-11-14 21:47:12 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
namespace SAM
{
const int maxn=100100;
int tr[maxn][26];
int fail[maxn],len[maxn],p1[maxn],p2[maxn];
int tot=1,last=1;
vector<int> G[maxn];
void clear()
{
for(int i=1;i<=tot;i++)
{
memset(tr[i],0,sizeof(tr[i]));
G[i].clear();
p1[i]=p2[i]=len[i]=fail[i]=0;
p1[i]=inf;
}
tot=last=1;
}
void extend(int w,int x)
{
int p=last;
int np=++tot;
p1[np]=p2[np]=x;
while(p&&!tr[p][w])
{
tr[p][w]=np;
p=fail[p];
}
if(!p) fail[np]=1;
else
{
int q=tr[p][w];
if(len[p]+1==len[q])
fail[np]=q;
else
{
int nq=++tot;
len[nq]=len[p]+1;
memcpy(tr[nq],tr[q],sizeof(tr[q]));
fail[nq]=fail[q];
fail[q]=nq;
fail[np]=nq;
while(p&&tr[p][w]==q)
{
tr[p][w]=nq;
p=fail[p];
}
}
}
last=np;
}
void build()
{
for(int i=2;i<=tot;i++)
G[fail[i]].pb(i);
}
void dfs(int u)
{
for(auto v:G[u])
{
dfs(v);
p1[u]=min(p1[u],p1[v]);
p2[u]=max(p2[u],p2[v]);
}
}
}
ll calc(string S)
{
SAM::clear();
for(int i=0;i<sz(S);i++)
SAM::extend(S[i]-'a',i);
SAM::build();
SAM::dfs(1);
vector<ll> val(sz(S)+5);
for(int i=2;i<=SAM::tot;i++)
{
int L=SAM::p1[i];
int R=SAM::p2[i];
int l=SAM::len[SAM::fail[i]]+1;
int r=SAM::len[i];
if(R-l<L) continue;
r=min(r,R-L);
val[L]+=r-l+1;
val[L+1]-=r-l+1;
val[R-r+1]--;
val[R-l+2]++;
}
for(int i=1;i<sz(val);i++)
val[i]+=val[i-1];
for(int i=1;i<sz(val);i++)
val[i]+=val[i-1];
ll ans=0;
for(int i=1;i<sz(S);i++)
ans+=val[i-1]*val[i-1];
return ans;
}
int n,k;
string s;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>k>>s;
ll L=0,R=1e18;
while(L<R)
{
ll mid=(L+R)/2;
int cur=0;
for(int r=0;r<k;r++)
{
if(cur==n) break;
if(calc(s.substr(cur,1))>mid) break;
int len=1;
while(true)
{
if(cur+len>n) break;
if(calc(s.substr(cur,len))>mid) break;
len<<=1;
}
int l2=1,r2=min(len,n-cur);
while(l2<r2)
{
int mid2=(l2+r2+1)/2;
if(calc(s.substr(cur,mid2))<=mid)
l2=mid2;
else
r2=mid2-1;
}
cur+=l2;
}
if(cur==n)
R=mid;
else
L=mid+1;
}
cout<<L<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 7684kb
input:
10 3 aaaaaaaaaa
output:
6
result:
ok single line: '6'
Test #2:
score: 10
Accepted
time: 2ms
memory: 7684kb
input:
10 1 abbbaabbba
output:
289
result:
ok single line: '289'
Test #3:
score: 10
Accepted
time: 2ms
memory: 7612kb
input:
10 2 cacabbcbca
output:
11
result:
ok single line: '11'
Test #4:
score: 10
Accepted
time: 0ms
memory: 7704kb
input:
10 4 aabbccddaa
output:
1
result:
ok single line: '1'
Test #5:
score: 10
Accepted
time: 2ms
memory: 7708kb
input:
10 4 ababbbabab
output:
2
result:
ok single line: '2'
Test #6:
score: 10
Accepted
time: 2ms
memory: 7648kb
input:
10 2 ababbaaaba
output:
12
result:
ok single line: '12'
Test #7:
score: 10
Accepted
time: 2ms
memory: 7704kb
input:
10 1 baabaababa
output:
156
result:
ok single line: '156'
Test #8:
score: 10
Accepted
time: 0ms
memory: 7652kb
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: 7632kb
input:
50 10 aababaaabaabaaabababaaaaaabbbababbaababaaaabababba
output:
17
result:
ok single line: '17'
Test #10:
score: 10
Accepted
time: 3ms
memory: 7912kb
input:
50 5 bbbaabbbbbaabaababbbbbbaaaaababbbaaabaaaaaabbabaab
output:
91
result:
ok single line: '91'
Test #11:
score: 10
Accepted
time: 3ms
memory: 7716kb
input:
50 5 adbabadbabadbabadbabadbabadbabadbabadbabadbabadbab
output:
412
result:
ok single line: '412'
Test #12:
score: 10
Accepted
time: 2ms
memory: 5600kb
input:
50 3 caaabcaaabcaaabcaaabcaaabcaaabcaaabcaaabcaaabcaaab
output:
3222
result:
ok single line: '3222'
Test #13:
score: 10
Accepted
time: 3ms
memory: 7580kb
input:
50 1 cadabcadabcadcadabcadabcadcadabcadcadabcadabcadcad
output:
407986
result:
ok single line: '407986'
Test #14:
score: 10
Accepted
time: 0ms
memory: 5664kb
input:
50 15 bbbbbbabaabaaaabaaabbaababbaaabababbbbaabaababaaba
output:
3
result:
ok single line: '3'
Test #15:
score: 10
Accepted
time: 0ms
memory: 7632kb
input:
50 20 baaaaaaaabbabbababbaaaabbabaabbababbbabbbabaaabaaa
output:
2
result:
ok single line: '2'
Test #16:
score: 10
Accepted
time: 3ms
memory: 7624kb
input:
50 6 ababbbbaaaaabbbabaabaaabaaabababababbaaaababbbbbab
output:
65
result:
ok single line: '65'
Test #17:
score: 10
Accepted
time: 0ms
memory: 5876kb
input:
50 1 aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa
output:
129389
result:
ok single line: '129389'
Test #18:
score: 10
Accepted
time: 0ms
memory: 5664kb
input:
50 1 acbcaabcababaacbbacaabcbacccbbaacaccbabccacaccaabb
output:
16446
result:
ok single line: '16446'
Test #19:
score: 10
Accepted
time: 0ms
memory: 7716kb
input:
50 14 ccaccaccaccaccaccaccaccaccaccaccaccaccaccaccaccacc
output:
6
result:
ok single line: '6'
Test #20:
score: 10
Accepted
time: 3ms
memory: 7584kb
input:
50 24 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
output:
2
result:
ok single line: '2'
Test #21:
score: 10
Accepted
time: 3ms
memory: 7636kb
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: 6ms
memory: 7892kb
input:
200 1 cabaababbabbbcabcbcaacbccaabcacbccaabbccccbcabbcacbbcbacbccaabbbbcbcabbacabbacccbbbbbacccabcccaaacbcbaaaccabbbabcaabbbababcabccbccbaaabbbcbccbbcacbbabbaabcacbcaccccccaaaccabbaaabbbcbbccbcabbbcabcccabb
output:
2192936
result:
ok single line: '2192936'
Test #23:
score: 20
Accepted
time: 6ms
memory: 5836kb
input:
200 2 cbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaacbaa
output:
1196175
result:
ok single line: '1196175'
Test #24:
score: 20
Accepted
time: 7ms
memory: 7676kb
input:
200 3 acabacbacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacacabacacabacbacacabacbacacabacacabacbacac
output:
1550907
result:
ok single line: '1550907'
Test #25:
score: 20
Accepted
time: 3ms
memory: 7744kb
input:
200 7 hefdaadcdgfecghbgcbggfgdfchchgbdfafghahacgbbcebfchadbcechdacacccahggadbdacbggadbgceacgeedfafbhhfhaacdccefddbfaffcdggabhhcghcbfbedddeheaeaabdahhbhcefeededbfdafghdahcfbfbcbbdgccffhaeggcdhdcghghfaaefechd
output:
1134
result:
ok single line: '1134'
Test #26:
score: 20
Accepted
time: 0ms
memory: 7908kb
input:
200 11 lmmeigmkegfbcmhfedchmeckbnbgjlfljahjleeldlnkdlnkngaeiiblangdlkdfjchalckfhfcjgljlelebhfacafkjknknjjfklnhcnlgkkjmhfafmhehgehmejajabgaikfnclihbkmeckghfljgfmajflilgcimamgljlhjkfhgjcbcddfjlnchcgedmghdlfaib
output:
155
result:
ok single line: '155'
Test #27:
score: 20
Accepted
time: 3ms
memory: 7620kb
input:
200 19 cdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbaccdcccacbac
output:
133
result:
ok single line: '133'
Test #28:
score: 20
Accepted
time: 6ms
memory: 7756kb
input:
200 16 acdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbddbaacdbacdbddbaacdbacdbddbaacdb
output:
481
result:
ok single line: '481'
Test #29:
score: 20
Accepted
time: 6ms
memory: 5836kb
input:
200 25 abacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacdacdabacdabacdacdabacda
output:
99
result:
ok single line: '99'
Test #30:
score: 20
Accepted
time: 5ms
memory: 7716kb
input:
200 25 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadkgmivxnitlfmciurqeqnqghxveqrxidxbmzlpdveuucarjwdqyiiaegadulttqmkzinvxalbvnccchfvjechxnufmcmofrdkesmkjeiobfzwbppknslhtxoranwbjnxggudgjmjrigintzxkusvvaqwhuwvoyiz
output:
6
result:
ok single line: '6'
Test #31:
score: 20
Accepted
time: 3ms
memory: 7744kb
input:
200 37 aaaaaaaaaaaaabdecdebedebaaaaaaaaaaaaaaaacebcbcecaebeaaaaaaaaaaaaaebcddecebbebaaaaaaaaaaaaaaeadaaecdadbaeaaaaaaaaaaaaaccbabdbbeedaeaaaaaaaaaaaaadbddbebeddcbeaaaaaaaaaaaaaaceeedcecdadbaaaaaaaaaaaaaaaaaa
output:
10
result:
ok single line: '10'
Test #32:
score: 20
Accepted
time: 3ms
memory: 7748kb
input:
200 64 bbabbbaaaabababaabbaaaabbabbbaabbaababababbbaabbbbbbbbbabbbbabaababbbbabbbabbbaabbbbbaabaabbbbbbababbbabbaaaababbbbabbbaaaaaaabbabbaabaabaabbaaabbaaaaaabaabbbbaaaaabbababbaabaabbbbbabbbbababbbbaaabaab
output:
2
result:
ok single line: '2'
Test #33:
score: 20
Accepted
time: 3ms
memory: 7956kb
input:
200 49 abbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbabbab
output:
10
result:
ok single line: '10'
Test #34:
score: 20
Accepted
time: 7ms
memory: 7736kb
input:
200 57 zbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbizbzbizbzbizbizbzbizbz
output:
3
result:
ok single line: '3'
Test #35:
score: 20
Accepted
time: 6ms
memory: 7952kb
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: 31ms
memory: 7804kb
input:
1000 153 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
28
result:
ok single line: '28'
Test #37:
score: 20
Accepted
time: 23ms
memory: 8032kb
input:
1000 79 babacbbcacbbccccababbacbacacbbcabcabbaaabccbacbaacccaaaaabbcabaabcaaabccccbbaabbcaccaaacccbaaacaacccaccababaacbcbbacbcbbbcccbbcbaaababbcbacaacaccbcacaaccbbbcaabcaababbcbbabbccaccbccabaacbcacbbccbbcbaaccbcaacccacccccabbbabccacbbbbcaabccccacababacaccacbcccbcccbaccabaacbaccabbcbbacaabcbcacccaac...
output:
200
result:
ok single line: '200'
Test #38:
score: 20
Accepted
time: 22ms
memory: 7736kb
input:
1000 6 ahcfaddebbbccheeffbfdbbbdcjhdefhcibhgjbgeaigaaifcbdfbjdjiddicbhagggaaaajiejjjfdabcjjjceieaijacjbaecifacgdajcigfababaddecfehdhfbfjhdahchahiiiafaibdbbdegeachfdicciaegdcagaahgdgebdhbdejajafajjjfdjfjdijjgahjdjjjifeejjbachjaiacgjfhccebjgddjehiecibjfheicgihfdabhbdiijbcdgffaedcejecciddahjajdfjiddhgc...
output:
237763
result:
ok single line: '237763'
Test #39:
score: 20
Accepted
time: 22ms
memory: 7792kb
input:
1000 79 cfbdcgcdcdgabebecbbgcebcgefcbdageefffaddafegeabdagdaaabeaedgabgedafdegdggbedcceafgegbceceebaaadbccgadebeaeebcaggdbdgefeaeegafgbaeegaadbcaeddceecacbecdgfaefaeagdbaadbdfceedgdabfbaadcffgbedfgbbdddbcgdfccaeabbgabdfgefcefbaadefcfagebegfafbabfcbaagbedacfgffefadcdecbabbcfaegcgcddbagceaaaabcfacgfbe...
output:
91
result:
ok single line: '91'
Test #40:
score: 20
Accepted
time: 21ms
memory: 7804kb
input:
1000 3 htspasbnfsqdnsppbkaaprldgjpfaikdjcaojaejdtipsrkrfddlkepkqbjprsejnpcqigqjkmpqfhbbglccmtrrngoopfscopnocqkfesphqnteofsinkqqopnknbkejodkpnmjobgcisimpsgnqqidtfsdjakntlkgtgnnaietrijhgksrsnohilbrrtcpndciksonfptfkljhhisihcngqsdmgreakrrgmgnspabhfmegnmhtlhkrfnliipssjcbdikfgqmjtaltootaaopdrfrfrdaelnbrdd...
output:
1022595
result:
ok single line: '1022595'
Test #41:
score: 20
Accepted
time: 20ms
memory: 7740kb
input:
1000 14 jmgovzbodqoznwcmegtwxcunytkvnnoqixxjgbspvoochcctbmgfcofmdctzmpxwqwztunedfpvrdbbgujrmowvbahioiwnewuidqkajpxdkwckpmmbrkbrebgiqdktjgeaktrcgcaduslvxlpqofscjzmjmjyyzpvogthoglxsdvqpvcccfljopkcudctgxjovrppnbyzairtebpggtheutanrfalcsakvcreyxxchzalfaybwptnbulyteeuapgoscpzvigwetrjhtzxtgzhehhknztxhcvrbw...
output:
11558
result:
ok single line: '11558'
Test #42:
score: 20
Accepted
time: 26ms
memory: 7968kb
input:
1000 102 bacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaabacaab...
output:
384
result:
ok single line: '384'
Test #43:
score: 20
Accepted
time: 23ms
memory: 7740kb
input:
1000 11 dfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidabdhgcdfbkbjdlafmdkfifefkbcblkmjhjhidab...
output:
15796914
result:
ok single line: '15796914'
Test #44:
score: 20
Accepted
time: 27ms
memory: 7692kb
input:
1000 3 cmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhdekggicmfkhennaifblffiofabfdkmlcklkndoiognhfihbocmabiacablhoadfenghhd...
output:
6797306034
result:
ok single line: '6797306034'
Test #45:
score: 20
Accepted
time: 26ms
memory: 7788kb
input:
1000 1 deebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcabbaeeaadeebcab...
output:
13523081623
result:
ok single line: '13523081623'
Test #46:
score: 20
Accepted
time: 28ms
memory: 7744kb
input:
1000 176 ddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddcddcaaddc...
output:
15
result:
ok single line: '15'
Test #47:
score: 20
Accepted
time: 25ms
memory: 7820kb
input:
1000 176 dcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbdcbdbd...
output:
26
result:
ok single line: '26'
Test #48:
score: 20
Accepted
time: 30ms
memory: 5684kb
input:
1000 1 bbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbabbabaabbabaabbabbabaabbaba...
output:
674957710334
result:
ok single line: '674957710334'
Test #49:
score: 20
Accepted
time: 30ms
memory: 7816kb
input:
1000 27 aacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebebebeaacabebebebeaacabebeaacabebe...
output:
97930
result:
ok single line: '97930'
Test #50:
score: 20
Accepted
time: 26ms
memory: 7748kb
input:
1000 92 agddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghjgdagddghjgdcdaagddghjgdcdaagddghj...
output:
91
result:
ok single line: '91'
Test #51:
score: 20
Accepted
time: 27ms
memory: 7808kb
input:
1000 229 acabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaacaacabaacaacabaacabaacaacabaacabaa...
output:
6
result:
ok single line: '6'
Test #52:
score: 20
Accepted
time: 26ms
memory: 7756kb
input:
1000 387 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1
result:
ok single line: '1'
Test #53:
score: 20
Accepted
time: 24ms
memory: 8012kb
input:
1000 79 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaautinovsqokcxceilfvzjuysmgbiyekhrjqvuhhncnpwdtvsyztzgtalquqtzfcvkwymtgamyvbgfzwdauxdetdjumnyi...
output:
107
result:
ok single line: '107'
Test #54:
score: 20
Accepted
time: 17ms
memory: 5796kb
input:
1000 15 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaeykkmvfmjxnnkseynhnyfbqpwwixbaaaaaaaaaaaaaaaaaaaaaaaaaaaaarpatbemszmhqxaxnyvkrdyqhbghuuaaaaaaaaaaaaaaaaaaaaaaaaaaaaayslipjklioorocacxthuhpczyttxgaaaaaaaaaaaaaaaaaaaaaaaaaaaaahakpigwtewvfeumzjluchidvlsfobaaaaaaaaaaaaaaaaaaaaaaaaaaaaazwzvxvonganwxwbacknxoaozsirfuaa...
output:
11461
result:
ok single line: '11461'
Test #55:
score: 20
Accepted
time: 19ms
memory: 7764kb
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: 5014ms
memory: 18676kb
input:
50000 1 eaadcfedcbcceccfccdbbeccbcaeaaeffbbbecedddfacfdeaadbbebdcbaafcefedddbfdfbcdfbccbdcdcbccbebcbddfcdaacfefffbafcdfefabbecbcacdfcabbebedacdbcdfebbccfeecddcfbdfbebffafdbaeddcbbecfdbfaecbeeffcdfbceefeddfdadfadfadfeafaeddbccabebeaccadbfdfbedededecccbcdcafddefaefccbfbcdaeedfeaabdceafeaabcdabbceddecc...
output:
10929072780271
result:
ok single line: '10929072780271'
Test #57:
score: 40
Accepted
time: 3495ms
memory: 16584kb
input:
50000 1 gkhkjgfdaleeedqndpdmloccjpmfjccgljhflhdlponlqkmdeeipldediiocnmbqpemqqdpgjpmhccbalagqpndfkbpdmoegqqmogcbnnhhlbkgkaenqnoqelfoipclpadgppqmglmohdmeofgplpgclpkpgkpfggnkedcjoqfpbfffnqbmiaahhnkbacqgndchjkgknmgnhgbajnaahaeieqbcjjbhkqablmannnhhkcnlikjhikdjpeknpjgccbopfcgbaldjkckhdaopiifpojlomacnjkgod...
output:
3919799366097
result:
ok single line: '3919799366097'
Test #58:
score: 40
Accepted
time: 3206ms
memory: 15860kb
input:
50000 2 dywnjsdsqucmugwjznrryntujlauuycoadwemeamjhdfttkusnlddamdphpocuuyybnsjhqbopghiofjytxxkqeswozivewcmqhdaokbkjgkqfcccvcgjzoazunxmborqibfnyyhsrfvbldesvurxywquncvftcuazwzgdugsdtjlyzbxzeyzmqlvfjthnxujrcidjmvpwtcxjyiexqwqsqnrjxzwklygwhsshsxgxswyneojeualdftvjhwpmqbuwbtgidwfuvgqwcurpnrkfskoqkdzkbvfukc...
output:
445287879854
result:
ok single line: '445287879854'
Test #59:
score: 40
Accepted
time: 5381ms
memory: 20540kb
input:
50000 1 dcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddcccddc...
output:
260329176674704
result:
ok single line: '260329176674704'
Test #60:
score: 40
Accepted
time: 5273ms
memory: 20536kb
input:
50000 2 bdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceffeijdjhcbdceff...
output:
219715009632838
result:
ok single line: '219715009632838'
Test #61:
score: 40
Accepted
time: 4740ms
memory: 20588kb
input:
50000 3 nihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopnmkecpogjgbakpanbdnpenihabedjblqqhlepopn...
output:
582704337052667
result:
ok single line: '582704337052667'
Test #62:
score: 40
Accepted
time: 5154ms
memory: 20236kb
input:
50000 2 bpzeonrxhvmmwwkyfurffcakwgajxuqxdvfausbbokvavccmtoxsfswyyzdgklnfstlmzngwxdslkzxekqyuqjjhxudzbfectlxcxoeiwflxhkyvgbgmwsczpcguwobmfspabeutdfwqtsnryzhhtmlhpoaweuillzrepgogirppxbkktnbljrylwrpltsbinaekcvjlqgizbpzeonrxhvmmwwkyfurffcakwgajxuqxdvfausbbokvavccmtoxsfswyyzdgklnfstlmzngwxdslkzxekqyuqjjh...
output:
52863724029762619
result:
ok single line: '52863724029762619'
Test #63:
score: 40
Accepted
time: 2541ms
memory: 18084kb
input:
50000 14 dgeliicbdaaijggngndehgbnhiaajjkaalenhaceemblmildbbmlkngcekjhbcblbckiianfcihfndiijbjdhdkgbifdbegfnmghaakdgajbkehnkhcnfjfalcjkcemnkhdkkjmdamdmajgehnkkdnbedklndgfkagdaaljekjhfmnaedllnjmndlhifmnllkhebmjlhkfgjijkcjffbenemhjljmbgbjhngnjeafjlefjdfkbjefkkajfjidckbegeieifcfeghmjhmejhlclfihakkimkhnjn...
output:
1814156853
result:
ok single line: '1814156853'
Test #64:
score: 40
Accepted
time: 2196ms
memory: 17020kb
input:
50000 27 omokibdejmnllgbdqaaclogbqjdlmkplnfcmankchcboeqkjonlbbqihjiopffaejqlapfjjdpjfpqnlgdhniqpmcqmbnpgmfclanifoqneqnhnbeaoohqboqappchppnpbjompkbcnjqijmgnkddccoogaoablqlnfqecnqileeioabgpaemomojoghhboqaajgajdjjiiiomdhoijmgnpeqbmiilaqclhaonnmeojhmhnilqbqhpfjcklacldqbknomebghgeoqmjhqcnpeifiillbhhdeqqb...
output:
214605170
result:
ok single line: '214605170'
Test #65:
score: 40
Accepted
time: 3062ms
memory: 17428kb
input:
50000 62 beacebecdedbeddedededdecdadadcbeaedbbacbcdceadabbecaabecbcbaacddeeabdcebdaceaaaabacedabbedebeaacbeadadeadeeaccdeecbeadadebdeeaadcccceaaedbcceadebdeeeaddeddbcdecdaeacccdccecbeaaebcaedaaaccbbddbbceecbcdccdeddeccbbeacceaceabeeabeddeaababbbdbaebacdbdddeadecdddebcadeeaaddcdcdadceeabdcaccaeeecbed...
output:
56128859
result:
ok single line: '56128859'
Test #66:
score: 40
Accepted
time: 2579ms
memory: 20228kb
input:
50000 79 bmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejggbmdadobmmcgfkldmhgimjemgohibnejgg...
output:
19534901514
result:
ok single line: '19534901514'
Test #67:
score: 40
Accepted
time: 2652ms
memory: 20376kb
input:
50000 96 bqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpkepcppemnrmcojlpaalboqcbqkslaqndbqhefkdgcegkkmpffckokemicgfqdknbkaaqqaccqopghpke...
output:
42964961476
result:
ok single line: '42964961476'
Test #68:
score: 40
Accepted
time: 2165ms
memory: 11756kb
input:
50000 88 cabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacabbcabbddbacabbcabbddbacabbddbacab...
output:
38369677770
result:
ok single line: '38369677770'
Test #69:
score: 40
Accepted
time: 2022ms
memory: 16680kb
input:
50000 103 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
4645311
result:
ok single line: '4645311'
Test #70:
score: 40
Accepted
time: 2409ms
memory: 19320kb
input:
50000 115 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
3275390
result:
ok single line: '3275390'
Test #71:
score: 40
Accepted
time: 2622ms
memory: 18412kb
input:
50000 334 bgadgbafgghbjhdfddjcbfgcgbhaecajjhhbgbadiicbcdccjjhbcjdihidehdbgfhhjediaahecjdjehifbabhbcjfdbghfgigegchhdbhdgdchgjgcdfbjbcaiigfhgbjfaagjjgiihaiaeajjhhdfifhciebidabiefifhedcajfcbhdbceaggjaaedadhjhgigibbdhaficfcciaaefcbcdceddhihiiffadedgcdhdigijdebhchejabfgahehggafhacbhijbadhfceihfeeejfhghci...
output:
160984
result:
ok single line: '160984'
Test #72:
score: 40
Accepted
time: 2227ms
memory: 16180kb
input:
50000 453 rgyzchgqoskbomrmkyapwmpvgaynsjjvfmirllorsrgmlvwgzeiaorzhzkqyvldplrwjshxmtkwxfprbwxtxejpbbnignbijtafznifvdaitywznmvbdkpohisyabydkvsigplhuafuswlevunwladpvuqdcqxxkekyytgithubwhmxqxmmxfkmtctekslcpzbatzkdksognowpiizhfzzifwkjixndpskojfxyczmoroefnvizjsjfnnotkhtfyjwgmgoqtjtkyfbdvsjotnxsefqpahkaugr...
output:
38614
result:
ok single line: '38614'
Test #73:
score: 40
Accepted
time: 2635ms
memory: 20180kb
input:
50000 626 anbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpiaesdcrjfnipfspmlanbkiqksljdcjbmhpi...
output:
8946471
result:
ok single line: '8946471'
Test #74:
score: 40
Accepted
time: 2724ms
memory: 20180kb
input:
50000 875 adgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjaggadgbggbjiedhfjagga...
output:
1508468
result:
ok single line: '1508468'
Test #75:
score: 40
Accepted
time: 1831ms
memory: 13812kb
input:
50000 710 acadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccacadacadbaccacadacadbaccacadbaccac...
output:
1895757
result:
ok single line: '1895757'
Test #76:
score: 40
Accepted
time: 2883ms
memory: 18740kb
input:
50000 1335 ebadcedecceabbdacddbcbbdbbccdbdcaaddbaeecbecabcabdcbdcbcdbdcccabbbaecdbcaeaaeadbabacdbaecccecedabdeaadbaaeeaedacaecebabecbbccebeeceecbbecbacacaebbccbecbcbddedadcabaaeeecbabadceeeeccaedbeaeddaecabcddbeaabcdeedcacecdebddbbbbbbdbbcbebccadbdacdcdbceeadbdeadcbaadaeecebbecdaaaebbbcbadaebbdcdabe...
output:
4248
result:
ok single line: '4248'
Test #77:
score: 40
Accepted
time: 2408ms
memory: 18480kb
input:
50000 3526 ghfjgjajgiafjjgjfgicedjeaiicceighggccddcegfgcagbffeagjcfjbbdehajdahejcedgiifacbbdhhbdacgbjggheihahgabjjaajdeehdgigjeggfedhfcehafbeibeebefjgaijahgibiebbedjcajahdhehgcdceafhfeafbcgajhffeadabfhdcebjcbcchjfhafajhhjdigechhfbhbgbdbgdcdjcaddfiedicbjigiiejafdhdfbdabfhcbaahadaijgbgdjgjdbjihfehgbhi...
output:
88
result:
ok single line: '88'
Test #78:
score: 40
Accepted
time: 2522ms
memory: 20844kb
input:
50000 3526 dfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjadfbcfgfgagjad...
output:
303
result:
ok single line: '303'
Test #79:
score: 40
Accepted
time: 1649ms
memory: 11704kb
input:
50000 4428 bcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbabccbcccbabcccbabccbcccbab...
output:
330
result:
ok single line: '330'
Test #80:
score: 40
Accepted
time: 2354ms
memory: 20428kb
input:
50000 5074 abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa...
output:
269
result:
ok single line: '269'
Test #81:
score: 40
Accepted
time: 3745ms
memory: 20216kb
input:
50000 26013 abaaabbabbbbbabaaaabbababaaaaaaabababbbbababbabbabaabbaaaaaabbabbbabaaabbababbbaabaaaaaaababbababbbaaabababbbbabaaabaaabaabaababbaaaaaaaaababbbbaabaabababbbbbbaaaabaaaabaaabbbaaaababbaaabbaabaaabbbaaaabaaabbbaabbbabbaaabababaaaaabbabbaaaabbaaabbbbbabbabaaaababbbaaaabbbaabbbaabbbbabbaabaa...
output:
1
result:
ok single line: '1'