QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597740#6338. ChorusMispertion61 1661ms5736kbC++233.2kb2024-09-28 18:36:192024-09-28 18:36:21

Judging History

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

  • [2024-09-28 18:36:21]
  • 评测
  • 测评结果:61
  • 用时:1661ms
  • 内存:5736kb
  • [2024-09-28 18:36:19]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"

const ld PI = 3.1415926535;
const int N = 5e3+5;
const int M = 50 + 1;
const int mod = 1e9+7;
const int infi = 1e15;
const ll infl = LLONG_MAX;
const int P = 31;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) { 
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

int n, k, ans, dp[N][N], ps[2 * N], R[2 * N];
string s;

void normalize(){
    vector<int> psa = {}, psb = {};
    for(int i = 1; i <= 2 * n; i++){
        if(s[i] == 'A')
            psa.pb(i);
        else
            psb.pb(i);
    }
    string ns = "#";
    int balance = 0, skp = 0, cur = 0;
    for(int i = 1; i <= 2 * n; i++){
        if(s[i] == 'A' && skp){
            skp--;
            continue;
        }
        if(s[i] == 'B' && balance == 0){
            ns += "A";
            ans += (psa[cur] - sz(ns) + 1);
            balance++;
            skp++;
            i--;
            cur++;
            continue;
        }
        if(s[i] == 'B'){
            ns += "B";
            balance--;
        }else{
            ns += "A";
            cur++;
            balance++;
        }
    }
    s = ns;
}

pii getans(int C){
    vector<pii> dp(n + 2, {infi, infi});
    dp[n + 1] = {0, 0};
    for(int i = n; i >= 1; i--){
        int cur = i, sm = 0;
        for(int j = i + 1; j <= n + 1; j++){
            while(cur < j && ps[j - 1] > R[cur]){
                sm += R[cur];
                cur++;
            }
            dp[i] = min(dp[i], {dp[j].F + (((ps[j - 1] + (ps[j - 1] - (cur - i) + 1)) * (cur - i)) / 2) - sm, dp[j].S + 1});
        }
        dp[i].F += C;
    }
    return dp[1];
}

void solve(){
    cin >> n >> k;
    cin >> s;
    s = "#" + s;
    normalize();
    queue<int> st;
    int cnt = 0;
    for(int i = 2 * n; i >= 1; i--){
        if(s[i] == 'B'){
            st.push(i);
            continue;
        }
        R[n - cnt] = st.front();
        ps[n - cnt] = i;
        st.pop();
        cnt++;
    }
    int lo = -1, hi = 10 * n * n + 1;
    while(lo + 1 < hi){
        int C = (lo + hi) / 2;
        auto e = getans(C);
        if(e.S > k)
            lo = C;
        else
            hi = C;
    }
    int C = hi;
    auto e = getans(C);
    cout << e.F + ans - (k * C) << '\n';
}   

signed main() {
    mispertion;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}   

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 16
Accepted

Test #1:

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

input:

1 1
BA

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

7 5
ABBAAABBABABBA

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

10 3
BABBABAABAABBABBBAAA

output:

26

result:

ok 1 number(s): "26"

Test #4:

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

input:

10 2
AAABBABABBAAABBBAABB

output:

11

result:

ok 1 number(s): "11"

Test #5:

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

input:

10 1
BBBBBBBBBBAAAAAAAAAA

output:

100

result:

ok 1 number(s): "100"

Test #6:

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

input:

10 2
BBBBBBBBBBAAAAAAAAAA

output:

75

result:

ok 1 number(s): "75"

Test #7:

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

input:

10 9
BBBBBBBBBBAAAAAAAAAA

output:

56

result:

ok 1 number(s): "56"

Test #8:

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

input:

10 10
BBBBBBBBBBAAAAAAAAAA

output:

55

result:

ok 1 number(s): "55"

Test #9:

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

input:

10 10
ABABABABABABABABABAB

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

10 2
ABAAABABABBBABABABAB

output:

14

result:

ok 1 number(s): "14"

Test #11:

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

input:

10 4
ABAABBAAABBBAAABBBAB

output:

2

result:

ok 1 number(s): "2"

Test #12:

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

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: 0ms
memory: 3596kb

input:

179 54
AAABABABABBAAABBABBABBABBBAAABAAAAABBBABAAAAABABBBAABBBABABBAABABAABABBBBABAABAABABABBBABBAABABBAABBAABABBAAABAAAAAAAABBAAAAABAAABBBBBBBABBAABBBABABAABBAABBABABABBABAAABABAAABABABBAABABAAABBABABABABABBAAABABBBBBBBAABBBAABABBBBABAABBAAAABAABBABABAABAAABABAAAABBBAABAAABBABABBBABAAABAABBBABBBBBA...

output:

41

result:

ok 1 number(s): "41"

Test #14:

score: 24
Accepted
time: 8ms
memory: 3664kb

input:

500 93
ABABAABBBBABAABAABAAAAABABBBBBABABBABAAAABAABBBBABAABBBAAABBABABAAAABAABBABAAABBAAABBBABBAAAAAABABABBBABABBBAABAAABAABABAAABAAABBAAABABBBAABBABBBABBBAABAAAABBBAABBBABAAAAAABABABBBABAAAABBBBBAABBBABAAABAABBBABABAABABBBBABBABBBBBBBABAAAABAABAABBABBBAABBBAAAAAAABBAABAAABBBABBBAAABABBBBAABBBABABB...

output:

235

result:

ok 1 number(s): "235"

Test #15:

score: 24
Accepted
time: 8ms
memory: 3664kb

input:

500 273
AAABBABAABAAABABAABBBABAAAABBAAABBABAAABBABABAAAABBBAAABBBAABAABAABBABABABABBAAABBBBBBBAABABBAABABBBAABBBBAAABAAAABABBABBBBBAABAABABAAAABBABABABAAAABBBAAAAABABBAABABABAAABBABAAAABABBBAAABABAABBAABBBAABAABBBAABABBBBABAAABAABBBBABBABAAABABBAABABBABBBBBBBABAABAAAABABABAAABABABABAABBAABBBABBBAAB...

output:

0

result:

ok 1 number(s): "0"

Test #16:

score: 24
Accepted
time: 8ms
memory: 3832kb

input:

500 1
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

250000

result:

ok 1 number(s): "250000"

Test #17:

score: 24
Accepted
time: 7ms
memory: 5736kb

input:

500 2
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

187500

result:

ok 1 number(s): "187500"

Test #18:

score: 24
Accepted
time: 6ms
memory: 3888kb

input:

500 499
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

125251

result:

ok 1 number(s): "125251"

Test #19:

score: 24
Accepted
time: 6ms
memory: 3896kb

input:

500 500
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

125250

result:

ok 1 number(s): "125250"

Test #20:

score: 24
Accepted
time: 8ms
memory: 3732kb

input:

500 10
ABAAABBBAABBABABAABAABABBBAABABABBAABABAABAABABABBBBABAABBAAAAAAABAABAABAABBABBABABBBABABBAABABBBBAABBBBABAAAAAAABAABAAABABABBAABABBABBAAAABAABBBAABABBABABBBBAAAABABBAAAAABAABBBBBBBBABBABBBAABBABBAAAABAABBBBBBAABBBAAAABABBAAABAABAABBBBAABBAAABBAABBAAAAABAAAAAABBAABABBABABBBABAAABBBAAABABAAABB...

output:

9129

result:

ok 1 number(s): "9129"

Test #21:

score: 24
Accepted
time: 6ms
memory: 3716kb

input:

500 500
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

0

result:

ok 1 number(s): "0"

Test #22:

score: 24
Accepted
time: 6ms
memory: 3628kb

input:

500 416
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

84

result:

ok 1 number(s): "84"

Test #23:

score: 24
Accepted
time: 7ms
memory: 3892kb

input:

499 167
ABAABBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAAB...

output:

2

result:

ok 1 number(s): "2"

Test #24:

score: 24
Accepted
time: 7ms
memory: 3660kb

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: 763ms
memory: 3844kb

input:

4918 2048
ABBBBBBAAAAABBBBAAAABBABBAAAABBBAABBBABABBAAAABBBAAAABAABBAAABAAABAABBAAABAAABBBAABBBBBBABAABBBBAAAAABBBBBABBBABABBBBBABAAAAAABAABBABBABBBBBAABAABAAAAAABBBBBAABBBABBBAAABBABBABBBAABBBBBBABBBABAABABABABABAAABBABABBAABAABBBBABABBAABABABABBAABABABBABABABAAABABBBABBBABBABBBBAAAABBBBAAABBBABBBA...

output:

138308

result:

ok 1 number(s): "138308"

Test #26:

score: 21
Accepted
time: 1192ms
memory: 4016kb

input:

5000 4332
AABBBABBBABBBABBAABABABAAAABAAABBABABBBABBBBBABABAAAAABAAAAAAABBBBABBBABABABBABAABAABBBBABBABBBAABABABBAABBAABABAAABBBABABBABBBBBABBAAABBABBAAAABAAABBBAAABBAABBABAAABABAABBAAABBABABABAAABBBAAAABAAAABAABBAABBAAABBABAAABBABAABBBABABBBBABBBAAABBBABBABBABBABBAAABABAAAAAAABABBBAAABABBBAABBAABAA...

output:

999

result:

ok 1 number(s): "999"

Test #27:

score: 21
Accepted
time: 1240ms
memory: 4076kb

input:

5000 1029
AAAAAAABAABBBAAABBBAABBABAABBBABBBBABAABAABBBBABAAAABBBAAAABBABABABABBBAAABAAABABBAAABAABAABAAAAAABAAABBBABBBABBBABBABAAAAAABBABABBBAAAAABBBAAAAAAAABBAABABAABBBAAAABBBBABBABBBAABBAAABBBBABAABABBBBBABBBAAAABAABBAAABBAAABAAAAAABAAABABBBAAAAABBBAAABBBAAAAABBABBABBBAAABAABABBBABBABBAABABBAAABA...

output:

0

result:

ok 1 number(s): "0"

Test #28:

score: 21
Accepted
time: 729ms
memory: 4068kb

input:

5000 1
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

25000000

result:

ok 1 number(s): "25000000"

Test #29:

score: 21
Accepted
time: 729ms
memory: 3836kb

input:

5000 2
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

18750000

result:

ok 1 number(s): "18750000"

Test #30:

score: 21
Accepted
time: 732ms
memory: 3832kb

input:

5000 4999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

12502501

result:

ok 1 number(s): "12502501"

Test #31:

score: 21
Accepted
time: 706ms
memory: 3824kb

input:

5000 5000
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

12502500

result:

ok 1 number(s): "12502500"

Test #32:

score: 21
Accepted
time: 1336ms
memory: 4040kb

input:

5000 10
ABABAABBAAAABAABBABBBBABAAABBBAAABAABAAABAAABAAABBBBBBBAAAABAABAABAAABBBAAABAAABABABABBABBAABABBABBAAAAABABABABAAABBBBABAABBABBBABBAABAABBBAAAAABBBAABABABBAAABBAAABAABAAABABAAABAAABAABAAAAABBBBBBBAABABAABBBBAABBAABAABABAAAABBBBBAABBBBBABAABAABABABAAAAABBBAAAABAABABBBABBAABABABAAAABAABBBAAAAB...

output:

1155101

result:

ok 1 number(s): "1155101"

Test #33:

score: 21
Accepted
time: 974ms
memory: 4088kb

input:

5000 1000
AABABBABABAAAABABABBABBABAAABABBABABAABBAABABBBBAABBABABABABAABBABABAAAABBBAAABBAABABBABBBAABBAAABABBAABABABBAABAABABBAABABBBBABAABAABABBBAAABBBABABABAABBAAAABBAABBAABBABABBBABABAABBAAAABBBAABABABBBABABAAABBABBAAAABABABABBABBBABABAAAABABBBAABABBBABABABABABAAABBBAABABBABABABABABAAAABABABABA...

output:

4212

result:

ok 1 number(s): "4212"

Test #34:

score: 21
Accepted
time: 731ms
memory: 3844kb

input:

5000 4138
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

862

result:

ok 1 number(s): "862"

Test #35:

score: 21
Accepted
time: 1661ms
memory: 4016kb

input:

5000 2379
ABAABABABABBABABAABABBABABAABABBAABBABABAABABABBAABABABABBABABAABABBAABBABABAABBABAABABABABBABABAABBABABABABAABABABBAABABABABBAABABBAABBABAABABABABBABAABABBAABBAABBABAABABABBABABAABABBAABBABABABAABBABABABAABBABABAABABABABBABABAABABABBABAABBAABABBABAABABBABABAABBABABABABABAABABBABABAABBAABB...

output:

1071

result:

ok 1 number(s): "1071"

Test #36:

score: 21
Accepted
time: 754ms
memory: 3780kb

input:

4999 1667
ABAABBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAA...

output:

2

result:

ok 1 number(s): "2"

Test #37:

score: 21
Accepted
time: 803ms
memory: 4092kb

input:

4999 1667
ABAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBB...

output:

2

result:

ok 1 number(s): "2"

Test #38:

score: 21
Accepted
time: 723ms
memory: 3916kb

input:

5000 1665
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

1388613

result:

ok 1 number(s): "1388613"

Subtask #4:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #39:

score: 0
Time Limit Exceeded

input:

59936 57569
BAAABBAAABBBABABAABABBAAABABABBABBAABABBBABBABABBBABABAABBBBAABABABAABAAAAAABABAAABBBBBABAAAABAAAABBAAABAAAAAABBAABAAABABAAABAABBABBBBBBABBBBABBAABBBABBBABAABAABAAABABBBBAAABAAAAAAABBABBAABABABBBAAABABBAABABBABAAAABABBBABABAAAABBABBBBBBAABBBBABBABBBAAAABAAAAAABBAAAABBBBBBBBAABBBBABABABBA...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%