QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#462285 | #6338. Chorus | Rafi22 | 100 ✓ | 3918ms | 115720kb | C++20 | 2.9kb | 2024-07-03 17:02:47 | 2024-07-03 17:02:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define int long long
#define ll long long
#define pb push_back
#define st first
#define nd second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
#define endl '\n'
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=998244353;
const int N=1000007;
__int128 DP[N];
int ile[N];
//int DP[N][N];
int nx[N];
__int128 pref[2*N];
__int128 P[N];
bool cmp(__int128 l1,__int128 m1,__int128 l2,__int128 m2)
{
return l1*m2<l2*m1;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
string s;
cin>>s;
vector<int>A={0},B={0};
FOR(i,0,2*n-1)
{
pref[i+1]=pref[i]+(s[i]=='B');
if(s[i]=='A')
{
P[sz(A)]=P[sz(A)-1]+pref[i+1];
A.pb(i+1);
}
else B.pb(i+1);
}
int it=n+1;
ROF(i,n,1)
{
while(it>i&&B[i]<A[it-1]) it--;
nx[i]=it;
}
__int128 L=0,R=1000000000000000000,sr,ans=-1;
while(L<=R)
{
sr=(L+R)/2;
FOR(i,1,n) DP[i]=(__int128)infl*infl;
deque<pair<__int128,__int128>>Q,F;
it=0;
FOR(i,0,n)
{
while(sz(Q)>0&&Q[0].st<=i) Q.pop_front();
if(sz(Q)>0)
{
DP[i]=DP[Q[0].nd]+sr;
ile[i]=ile[Q[0].nd]+1;
}
Q.pb({nx[i+1],i});
while(it<n&&nx[it+1]<=i)
{
__int128 b=1000*(-P[nx[it+1]-1]+(nx[it+1]-1)*it)+DP[it];
__int128 a=-it*1000;
while(sz(F)>1)
{
int ss=sz(F);
if(cmp(F[ss-2].nd-F[ss-1].nd,F[ss-1].st-F[ss-2].st,F[ss-1].nd-b,a-F[ss-1].st)) break;
else F.pop_back();
}
F.pb({a,b});
it++;
}
while(sz(F)>1)
{
if(F[0].st*i+F[0].nd>=F[1].st*i+F[1].nd)
{
__int128 X=1000*P[i]+F[0].st*i+F[0].nd+sr;
if(X<DP[i]||(X==DP[i]&&ile[-F[0].st/1000]+1<ile[i]))
{
DP[i]=X;
ile[i]=ile[-F[0].st/1000]+1;
}
F.pop_front();
}
else break;
}
if(sz(F)>0)
{
__int128 X=1000*P[i]+F[0].st*i+F[0].nd+sr;
if(X<DP[i]||(X==DP[i]&&ile[-F[0].st/1000]+1<ile[i]))
{
DP[i]=X;
ile[i]=ile[-F[0].st/1000]+1;
}
}
debug(i,DP[i],ile[i]);
}
debug(sr,DP[n],ile[n]);
if(ile[n]>k) L=sr+1;
else
{
ans=(DP[n]-k*sr)/1000;
debug(DP[n]-k*sr);
R=sr-1;
}
}
/*FOR(i,1,n) FOR(j,0,n) DP[i][j]=inf;
DP[0][0]=0;
FOR(j,1,k)
{
deque<pair<int,int>>Q,F;
it=0;
FOR(i,0,n)
{
// if(DP[i][j]!=inf) debug(i,j,DP[i][j]);
if(DP[i][j]!=inf) debug(i,j,DP[i][j]);
}
}
cout<<DP[n][k]<<endl;*/
cout<<(ll)ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 16
Accepted
Test #1:
score: 16
Accepted
time: 1ms
memory: 5768kb
input:
1 1 BA
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 16
Accepted
time: 0ms
memory: 3808kb
input:
7 5 ABBAAABBABABBA
output:
3
result:
ok 1 number(s): "3"
Test #3:
score: 16
Accepted
time: 1ms
memory: 3756kb
input:
10 3 BABBABAABAABBABBBAAA
output:
26
result:
ok 1 number(s): "26"
Test #4:
score: 16
Accepted
time: 1ms
memory: 3488kb
input:
10 2 AAABBABABBAAABBBAABB
output:
11
result:
ok 1 number(s): "11"
Test #5:
score: 16
Accepted
time: 0ms
memory: 3508kb
input:
10 1 BBBBBBBBBBAAAAAAAAAA
output:
100
result:
ok 1 number(s): "100"
Test #6:
score: 16
Accepted
time: 1ms
memory: 3708kb
input:
10 2 BBBBBBBBBBAAAAAAAAAA
output:
75
result:
ok 1 number(s): "75"
Test #7:
score: 16
Accepted
time: 1ms
memory: 3724kb
input:
10 9 BBBBBBBBBBAAAAAAAAAA
output:
56
result:
ok 1 number(s): "56"
Test #8:
score: 16
Accepted
time: 1ms
memory: 3492kb
input:
10 10 BBBBBBBBBBAAAAAAAAAA
output:
55
result:
ok 1 number(s): "55"
Test #9:
score: 16
Accepted
time: 1ms
memory: 3616kb
input:
10 10 ABABABABABABABABABAB
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 16
Accepted
time: 1ms
memory: 3564kb
input:
10 2 ABAAABABABBBABABABAB
output:
14
result:
ok 1 number(s): "14"
Test #11:
score: 16
Accepted
time: 1ms
memory: 3556kb
input:
10 4 ABAABBAAABBBAAABBBAB
output:
2
result:
ok 1 number(s): "2"
Test #12:
score: 16
Accepted
time: 0ms
memory: 3600kb
input:
10 4 ABAAABBBAAABBBAABBAB
output:
2
result:
ok 1 number(s): "2"
Subtask #2:
score: 24
Accepted
Dependency #1:
100%
Accepted
Test #13:
score: 24
Accepted
time: 1ms
memory: 3520kb
input:
179 54 AAABABABABBAAABBABBABBABBBAAABAAAAABBBABAAAAABABBBAABBBABABBAABABAABABBBBABAABAABABABBBABBAABABBAABBAABABBAAABAAAAAAAABBAAAAABAAABBBBBBBABBAABBBABABAABBAABBABABABBABAAABABAAABABABBAABABAAABBABABABABABBAAABABBBBBBBAABBBAABABBBBABAABBAAAABAABBABABAABAAABABAAAABBBAABAAABBABABBBABAAABAABBBABBBBBA...
output:
41
result:
ok 1 number(s): "41"
Test #14:
score: 24
Accepted
time: 2ms
memory: 3612kb
input:
500 93 ABABAABBBBABAABAABAAAAABABBBBBABABBABAAAABAABBBBABAABBBAAABBABABAAAABAABBABAAABBAAABBBABBAAAAAABABABBBABABBBAABAAABAABABAAABAAABBAAABABBBAABBABBBABBBAABAAAABBBAABBBABAAAAAABABABBBABAAAABBBBBAABBBABAAABAABBBABABAABABBBBABBABBBBBBBABAAAABAABAABBABBBAABBBAAAAAAABBAABAAABBBABBBAAABABBBBAABBBABABB...
output:
235
result:
ok 1 number(s): "235"
Test #15:
score: 24
Accepted
time: 2ms
memory: 3632kb
input:
500 273 AAABBABAABAAABABAABBBABAAAABBAAABBABAAABBABABAAAABBBAAABBBAABAABAABBABABABABBAAABBBBBBBAABABBAABABBBAABBBBAAABAAAABABBABBBBBAABAABABAAAABBABABABAAAABBBAAAAABABBAABABABAAABBABAAAABABBBAAABABAABBAABBBAABAABBBAABABBBBABAAABAABBBBABBABAAABABBAABABBABBBBBBBABAABAAAABABABAAABABABABAABBAABBBABBBAAB...
output:
0
result:
ok 1 number(s): "0"
Test #16:
score: 24
Accepted
time: 2ms
memory: 3548kb
input:
500 1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
250000
result:
ok 1 number(s): "250000"
Test #17:
score: 24
Accepted
time: 0ms
memory: 3676kb
input:
500 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
187500
result:
ok 1 number(s): "187500"
Test #18:
score: 24
Accepted
time: 2ms
memory: 3608kb
input:
500 499 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
125251
result:
ok 1 number(s): "125251"
Test #19:
score: 24
Accepted
time: 2ms
memory: 3656kb
input:
500 500 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
125250
result:
ok 1 number(s): "125250"
Test #20:
score: 24
Accepted
time: 2ms
memory: 3764kb
input:
500 10 ABAAABBBAABBABABAABAABABBBAABABABBAABABAABAABABABBBBABAABBAAAAAAABAABAABAABBABBABABBBABABBAABABBBBAABBBBABAAAAAAABAABAAABABABBAABABBABBAAAABAABBBAABABBABABBBBAAAABABBAAAAABAABBBBBBBBABBABBBAABBABBAAAABAABBBBBBAABBBAAAABABBAAABAABAABBBBAABBAAABBAABBAAAAABAAAAAABBAABABBABABBBABAAABBBAAABABAAABB...
output:
9129
result:
ok 1 number(s): "9129"
Test #21:
score: 24
Accepted
time: 0ms
memory: 3676kb
input:
500 500 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 24
Accepted
time: 2ms
memory: 3552kb
input:
500 416 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
84
result:
ok 1 number(s): "84"
Test #23:
score: 24
Accepted
time: 0ms
memory: 3564kb
input:
499 167 ABAABBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAAB...
output:
2
result:
ok 1 number(s): "2"
Test #24:
score: 24
Accepted
time: 2ms
memory: 3560kb
input:
499 167 ABAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAA...
output:
2
result:
ok 1 number(s): "2"
Subtask #3:
score: 21
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #25:
score: 21
Accepted
time: 18ms
memory: 4032kb
input:
4918 2048 ABBBBBBAAAAABBBBAAAABBABBAAAABBBAABBBABABBAAAABBBAAAABAABBAAABAAABAABBAAABAAABBBAABBBBBBABAABBBBAAAAABBBBBABBBABABBBBBABAAAAAABAABBABBABBBBBAABAABAAAAAABBBBBAABBBABBBAAABBABBABBBAABBBBBBABBBABAABABABABABAAABBABABBAABAABBBBABABBAABABABABBAABABABBABABABAAABABBBABBBABBABBBBAAAABBBBAAABBBABBBA...
output:
138308
result:
ok 1 number(s): "138308"
Test #26:
score: 21
Accepted
time: 17ms
memory: 4172kb
input:
5000 4332 AABBBABBBABBBABBAABABABAAAABAAABBABABBBABBBBBABABAAAAABAAAAAAABBBBABBBABABABBABAABAABBBBABBABBBAABABABBAABBAABABAAABBBABABBABBBBBABBAAABBABBAAAABAAABBBAAABBAABBABAAABABAABBAAABBABABABAAABBBAAAABAAAABAABBAABBAAABBABAAABBABAABBBABABBBBABBBAAABBBABBABBABBABBAAABABAAAAAAABABBBAAABABBBAABBAABAA...
output:
999
result:
ok 1 number(s): "999"
Test #27:
score: 21
Accepted
time: 16ms
memory: 4156kb
input:
5000 1029 AAAAAAABAABBBAAABBBAABBABAABBBABBBBABAABAABBBBABAAAABBBAAAABBABABABABBBAAABAAABABBAAABAABAABAAAAAABAAABBBABBBABBBABBABAAAAAABBABABBBAAAAABBBAAAAAAAABBAABABAABBBAAAABBBBABBABBBAABBAAABBBBABAABABBBBBABBBAAAABAABBAAABBAAABAAAAAABAAABABBBAAAAABBBAAABBBAAAAABBABBABBBAAABAABABBBABBABBAABABBAAABA...
output:
0
result:
ok 1 number(s): "0"
Test #28:
score: 21
Accepted
time: 12ms
memory: 4072kb
input:
5000 1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
25000000
result:
ok 1 number(s): "25000000"
Test #29:
score: 21
Accepted
time: 12ms
memory: 4148kb
input:
5000 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
18750000
result:
ok 1 number(s): "18750000"
Test #30:
score: 21
Accepted
time: 13ms
memory: 4160kb
input:
5000 4999 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
12502501
result:
ok 1 number(s): "12502501"
Test #31:
score: 21
Accepted
time: 12ms
memory: 4208kb
input:
5000 5000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
12502500
result:
ok 1 number(s): "12502500"
Test #32:
score: 21
Accepted
time: 14ms
memory: 4060kb
input:
5000 10 ABABAABBAAAABAABBABBBBABAAABBBAAABAABAAABAAABAAABBBBBBBAAAABAABAABAAABBBAAABAAABABABABBABBAABABBABBAAAAABABABABAAABBBBABAABBABBBABBAABAABBBAAAAABBBAABABABBAAABBAAABAABAAABABAAABAAABAABAAAAABBBBBBBAABABAABBBBAABBAABAABABAAAABBBBBAABBBBBABAABAABABABAAAAABBBAAAABAABABBBABBAABABABAAAABAABBBAAAAB...
output:
1155101
result:
ok 1 number(s): "1155101"
Test #33:
score: 21
Accepted
time: 17ms
memory: 4068kb
input:
5000 1000 AABABBABABAAAABABABBABBABAAABABBABABAABBAABABBBBAABBABABABABAABBABABAAAABBBAAABBAABABBABBBAABBAAABABBAABABABBAABAABABBAABABBBBABAABAABABBBAAABBBABABABAABBAAAABBAABBAABBABABBBABABAABBAAAABBBAABABABBBABABAAABBABBAAAABABABABBABBBABABAAAABABBBAABABBBABABABABABAAABBBAABABBABABABABABAAAABABABABA...
output:
4212
result:
ok 1 number(s): "4212"
Test #34:
score: 21
Accepted
time: 13ms
memory: 4076kb
input:
5000 4138 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
862
result:
ok 1 number(s): "862"
Test #35:
score: 21
Accepted
time: 15ms
memory: 4176kb
input:
5000 2379 ABAABABABABBABABAABABBABABAABABBAABBABABAABABABBAABABABABBABABAABABBAABBABABAABBABAABABABABBABABAABBABABABABAABABABBAABABABABBAABABBAABBABAABABABABBABAABABBAABBAABBABAABABABBABABAABABBAABBABABABAABBABABABAABBABABAABABABABBABABAABABABBABAABBAABABBABAABABBABABAABBABABABABABAABABBABABAABBAABB...
output:
1071
result:
ok 1 number(s): "1071"
Test #36:
score: 21
Accepted
time: 13ms
memory: 4256kb
input:
4999 1667 ABAABBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAA...
output:
2
result:
ok 1 number(s): "2"
Test #37:
score: 21
Accepted
time: 13ms
memory: 4172kb
input:
4999 1667 ABAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBB...
output:
2
result:
ok 1 number(s): "2"
Test #38:
score: 21
Accepted
time: 9ms
memory: 4028kb
input:
5000 1665 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
1388613
result:
ok 1 number(s): "1388613"
Subtask #4:
score: 26
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #39:
score: 26
Accepted
time: 195ms
memory: 9788kb
input:
59936 57569 BAAABBAAABBBABABAABABBAAABABABBABBAABABBBABBABABBBABABAABBBBAABABABAABAAAAAABABAAABBBBBABAAAABAAAABBAAABAAAAAABBAABAAABABAAABAABBABBBBBBABBBBABBAABBBABBBABAABAABAAABABBBBAAABAAAAAAABBABBAABABABBBAAABABBAABABBABAAAABABBBABABAAAABBABBBBBBAABBBBABBABBBAAAABAAAAAABBAAAABBBBBBBBAABBBBABABABBA...
output:
33013
result:
ok 1 number(s): "33013"
Test #40:
score: 26
Accepted
time: 325ms
memory: 13976kb
input:
100000 8782 ABBABAAAABBBBBABAAABABAABBABABAABAABAABBABBAAAAAABBAAAABBBAAABBABAAAAAABBAABAABABAAAAABABAAABBBABBAABBABABBBABBAAAABBBBABABAAABAAAAAAABBBAABABBBBBABABBAABABAAABBBAAABABBBBBABBAAAAABAAAAAABBBAABAABBABABBAAAAAAABAABBBBAABBABABBAAABBAAABAABABBBABAABBAAABABABAABBBBABAAABABAAAABAAAABBBAABAAAA...
output:
198328
result:
ok 1 number(s): "198328"
Test #41:
score: 26
Accepted
time: 322ms
memory: 13804kb
input:
100000 38214 AAABBABBAABABAAABABAABBAABBBBAAAAAABAAABABAABABAAAAABABBBBABAAAAABBAAAABABAABBBAABAAABBAAABAAABBAABBBABABBBBABAABABAAABBAAABBBBAABABABBAAAABBABAAABBBBABBABABAABAAABBBAABBABABABBABBAAAABABBBBBBBBABBAABABBBBAABBBBAABBBAAAAAABAABABAABBAABAABAABBAABABAAAABAABABBABAABBBAAABAABAABAAABAABBAABA...
output:
0
result:
ok 1 number(s): "0"
Test #42:
score: 26
Accepted
time: 219ms
memory: 14320kb
input:
100000 1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
10000000000
result:
ok 1 number(s): "10000000000"
Test #43:
score: 26
Accepted
time: 230ms
memory: 14268kb
input:
100000 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
7500000000
result:
ok 1 number(s): "7500000000"
Test #44:
score: 26
Accepted
time: 240ms
memory: 14020kb
input:
100000 99999 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
5000050001
result:
ok 1 number(s): "5000050001"
Test #45:
score: 26
Accepted
time: 238ms
memory: 14656kb
input:
100000 100000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
5000050000
result:
ok 1 number(s): "5000050000"
Test #46:
score: 26
Accepted
time: 358ms
memory: 14856kb
input:
100000 10 AABBABABAAABAABBAABBAABABABABBBBABAAAABAABAABBABBBABABBAABAABABBBABAABAAABABBBBAABBBAABAABBABBABAABABAAAABBBAAABBBABBBABAAAABBABAAAABAABBBBABBABBAABBBAAAABABBBABABAABABABABBAABBABAAABAAAAABABBBBBAAAABAABAAAABBABBABBAABABBBBBBABAABABBBABBBABAABBABABABAAAABABBBAAABBAABBBAABBBAAABBAAAABABBBBB...
output:
485360890
result:
ok 1 number(s): "485360890"
Test #47:
score: 26
Accepted
time: 373ms
memory: 13976kb
input:
100000 1000 ABAAAABBABAABBAAAAABBBABABAABAAAAAABABABABBAABBAAABAAABBAAABABBBBBABAABAAAABBBAABBBBBAAABAAAAAABABBBBAAAABBABBBABAABBAAABBABBBABBBBBABBBBBABAABABABBBBAABBABABABABAABABBAAAAAABABBBABBABBAAAABBBAAABBBBBBABAABBABAAAAABAABAAABBAABABAABBABAAAABABABABAAABBBBABAAAABAABABABBBABAABABABAAABAAABAAA...
output:
2235279
result:
ok 1 number(s): "2235279"
Test #48:
score: 26
Accepted
time: 240ms
memory: 14212kb
input:
100000 100000 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
0
result:
ok 1 number(s): "0"
Test #49:
score: 26
Accepted
time: 246ms
memory: 14208kb
input:
100000 76937 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
23063
result:
ok 1 number(s): "23063"
Test #50:
score: 26
Accepted
time: 357ms
memory: 13796kb
input:
100000 12845 AABBABABABAAAAABBBABABABBAABAABABBBAAAABABAABAABBBBAAABBABBABBAAAABBBABABBBBABABAABBAAABABBAAABBBBAAAABBBAAABBBAAABABABABAABAABBABBABBAAAAABBBBBABBBABABAAAABABABAAAABBBBAAABAABABBBBBABBBAABAAAABABBBAAABBAAABAABABABABBBBBBBAABABBABABAABBABAAAABBBBAAABBBABAAABAAABBBBBAABBABABAABBAABBAABAA...
output:
118675
result:
ok 1 number(s): "118675"
Subtask #5:
score: 13
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #51:
score: 13
Accepted
time: 2194ms
memory: 72208kb
input:
644992 518558 BBBAABABBAABBBABABBABABBABABAABABBAAABAAABABBBAABAABBAABAABABABAABAABABBBBBABBABABBABABBBBBBBBBBAABBBBBABBAABABBABBBABBBABBAAABABABAABBABABAABAAAAABABBBBBBABAABAAABBAAABBBBBAAABABAABABABAAAABAAABABABAABBABABBABAAABAAABBBABABAABBBAABABAABBBBABBBBABBAAAABBBAAAABAAAABBBBAAABBABBBBABABBBBA...
output:
141233
result:
ok 1 number(s): "141233"
Test #52:
score: 13
Accepted
time: 2960ms
memory: 112340kb
input:
1000000 810099 AABBBABAAAABBBBBABABABAAABBBBABAABBBBBBBABAABBBBBAAABABABBBAAABBBBAABABABAAAABABABBABABABBABABABBAAABAAAAABBAABABABBAABBBBABBBABBAAAABBBBBAABAABBAAAAABBAABBBAAABAABAABAABAAABBBBABAABABAAAABBBBABBABBBABBBBABBAAABABAABABBBAABAAAABBBABABBABABBAABAABBBBBAABABABAABABABBBBBABABAAAAABBBBABAB...
output:
121661020
result:
ok 1 number(s): "121661020"
Test #53:
score: 13
Accepted
time: 3411ms
memory: 110864kb
input:
1000000 68584 AABAAAAABAABBBAABBBAABAABAAABBAABAAABBABBAAABABBBBAAAABABABAABBBBABABAAAABBBBBBBAAAAAABBBABBAAABAAAABABBBBAAAAABBBAAAABBABBABABAAABABBBBBABABAAABBABAAABABBBBABBAABABBBBBBBBAABAAABBABAAAABABBBAABAABAABBBBAAAABBBBBAAABABABAABAAAAAAAAAABABBABABABAAAABAAAAABAABABBAAABBABBBBBABAABAABAABAAAA...
output:
0
result:
ok 1 number(s): "0"
Test #54:
score: 13
Accepted
time: 2295ms
memory: 115720kb
input:
1000000 1 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
1000000000000
result:
ok 1 number(s): "1000000000000"
Test #55:
score: 13
Accepted
time: 2395ms
memory: 115512kb
input:
1000000 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
750000000000
result:
ok 1 number(s): "750000000000"
Test #56:
score: 13
Accepted
time: 2556ms
memory: 115576kb
input:
1000000 999999 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
500000500001
result:
ok 1 number(s): "500000500001"
Test #57:
score: 13
Accepted
time: 2498ms
memory: 115476kb
input:
1000000 1000000 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
output:
500000500000
result:
ok 1 number(s): "500000500000"
Test #58:
score: 13
Accepted
time: 3821ms
memory: 110936kb
input:
1000000 10 ABABABABABABAAABABBBAAAABABBBBABABABABAAABAABABBAABBBBAABBAAAABBBBAABBAAAABABBABAABABBBBAAABABBABAAAABABBAABABAABABABABAABBBBBABABBBABABAAAAAABBAABAABABAABABBBAABBABBAABBBBBABAAAAABBABAAAABBABBAABBBBBABBAABABBBAAAAAABAAABAABAAAABBBBBBABBAABBBAAAAABABBBABAAAAAABABBABBBBBABBBABABBABAABAABBA...
output:
49686369526
result:
ok 1 number(s): "49686369526"
Test #59:
score: 13
Accepted
time: 3918ms
memory: 111180kb
input:
1000000 1000 ABABAAAABBBAAABBABBBABABABAAABAABABABAABABABBBBBAAAAAABAAAAABAABABABABABBABBBBAAAAABAABBAAABBAABAABBBABBAAABAAABABABBBBABABABBABBBABAABBBABBBABBABAAABABABBBAABBBABBBAAAABAAAABBAAABAABABABABBBABABABBBBBBAABBABABBBAABAABAABBABBBABABAAAABABAAAAABBAAAAABAABBABBAABAABAABAABBABBBAAAAABAAABBBA...
output:
179680697
result:
ok 1 number(s): "179680697"
Test #60:
score: 13
Accepted
time: 2764ms
memory: 115408kb
input:
1000000 100000 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
4500000
result:
ok 1 number(s): "4500000"
Test #61:
score: 13
Accepted
time: 2595ms
memory: 115424kb
input:
1000000 745782 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
254218
result:
ok 1 number(s): "254218"
Test #62:
score: 13
Accepted
time: 3749ms
memory: 111884kb
input:
1000000 96140 AAABBABABBABAABBAAAAAABABBBAABBABAAABABBAABABABBABBBABBAABBAAABBABBBAAAAABBAABBBAAAABABBBABBBABBABAABABABBAAAAAABABABABBBBAAABBBAABABBBABBABAAAABBAABAAABABBBBBAABABBBABAABBABAABABBAABBAABBAABABBAABABABBABABAAABBBABABAABABBABABAABAAAABBBABBAABBBABAAAABBABBABABAABAAABBABABBABBABBAABAABBB...
output:
2580941
result:
ok 1 number(s): "2580941"
Test #63:
score: 13
Accepted
time: 2606ms
memory: 115672kb
input:
1000000 721685 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
278315
result:
ok 1 number(s): "278315"
Extra Test:
score: 0
Extra Test Passed