QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#503252#8521. Pattern Search IIucup-team4435#AC ✓21ms53508kbC++202.2kb2024-08-03 17:14:042024-08-03 17:14:04

Judging History

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

  • [2024-08-03 17:14:04]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:53508kb
  • [2024-08-03 17:14:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

#define all(a) begin(a), end(a)
#define len(a) int((a).size())

constexpr int INF = 1e9;

struct info {
    int n;
    vector<int> max_pref;
    vector<pair<int, int>> for_suf;
    int ans = INF;

    info() {}

    info(char c, string s) {
        n = 1;
        max_pref.push_back(s[0] == c ? 1 : 0);

        for_suf.resize(len(s));
        for (int i = 0; i < len(s); i++) {
            if (s[i] == c) {
                for_suf[i] = {i + 1, 1};
            } else {
                for_suf[i] = {i, 1};
            }
        }
    }
};

info merge(const info &left, const info &right) {
    info res;
    res.ans = min(left.ans, right.ans);

    int n = len(left.max_pref) + len(right.max_pref);
    int m = len(left.for_suf);

    res.max_pref.resize(n);
    for (int i = len(left.max_pref); i < n; i++) {
        res.max_pref[i] = right.max_pref[i - len(left.max_pref)];
    }

    for (int i = 0; i < len(left.max_pref); i++) {
        int suf = left.max_pref[i];
        if (suf == m) {
            res.max_pref[i] = suf;
        } else {
            auto [nsuf, dlen] = right.for_suf[suf];
            if (nsuf == m) {
                res.ans = min(res.ans, len(left.max_pref) - i + dlen);
            }
            res.max_pref[i] = nsuf;
        }
    }

    res.for_suf.resize(m);
    for (int i = 0; i < m; i++) {
        auto [suf, dlen] = left.for_suf[i];
        if (suf == m) {
            res.for_suf[i] = left.for_suf[i];
        } else {
            auto [nsuf, dlen2] = right.for_suf[suf];
            res.for_suf[i] = {nsuf, dlen + dlen2};
        }
    }
    return res;
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    string s;
    cin >> s;
    if (len(s) == 1) {
        cout << "1\n";
        return 0;
    }

    vector<info> fib;
    fib.push_back(info('b', s));
    fib.push_back(info('a', s));
    for (int i = 2;; i++) {
        fib.push_back(merge(fib.back(), fib[len(fib) - 2]));
        if (i >= 5 && fib[i - 2].ans != INF) {
            cout << fib.back().ans << '\n';
            return 0;
        }
    }
}

详细

Test #1:

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

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

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

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

bb

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

ab

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

ba

output:

2

result:

ok 1 number(s): "2"

Test #8:

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

input:

bbba

output:

7

result:

ok 1 number(s): "7"

Test #9:

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

input:

abbbbbbbab

output:

20

result:

ok 1 number(s): "20"

Test #10:

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

input:

abbbbabbbabbbabbabaabbabb

output:

43

result:

ok 1 number(s): "43"

Test #11:

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

input:

bbbaabaabbbaabababbbabaaabaaabbbaaaabaabaaaaabbabbbababbabaaba

output:

94

result:

ok 1 number(s): "94"

Test #12:

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

input:

ababaaabbaaaabaaaaabbabbbababaabaabbabbabaaaabbbabbaaaabaaaabbbabaaaaabbbbbbbbaabaabaabbbbbbabbaabaaaabbbabbbaaabaaabaababaabbbbbbbbaabababaabbaabbbaaaaabb

output:

245

result:

ok 1 number(s): "245"

Test #13:

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

input:

aaaabbbbaaaaababababaaabbbbbbababbaaaaabaaaaaabababbaabbbabbabbbbabbbabaabaaaabababaabbbaaaaabbbabaabaaaababaabbaaabbbaaaabbbaabbaaabbabbbabbabbaababbbbabbbbbbabbaaabbaabbbbbbabababbaaababbaaaaaaabaabbaabbabbbaaaaaaaaaababbaaaabaabbbabbbaabbabbbaabaaaaaabaababaaaababaaaaaababbaaaaaabaabbaabbbbbbaaba...

output:

625

result:

ok 1 number(s): "625"

Test #14:

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

input:

aabaababbbbbbbbaabaaaaaabbbaababbabbabbaabbaaaaabaaaabbbbababbaabaaaaaabbbbabbbbbbbabbbaababbbbbbabaaababbaabaaaabbaababbbaaabbabababbbbbabbbaaaaaabbaabbbbabbabbaaaaaabababbabbbbabaabbbbbbbbaaabababbbbbbbaaababbbbbbabbbbabbaaabbbbaaabaaabbaabaabbaaaabababbabbabababbbaabbbbbabaaabbbabbbababbaababbbba...

output:

1608

result:

ok 1 number(s): "1608"

Test #15:

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

input:

aaababbbabbaabbbababbaaababaabbbbbabbbabbbabbabbaabbabbabaaabaabbbbbabababbbabaaaabaaababbabaaaabababbaabbaaaaaababaabababbbaaaabbababbbaaaaabababbaaaaabaabbbbbbaabaaaabbbaaababaabbbabaabaaababbbaaaaaabbbbbbbabbbabbaaaababbababaababaabbbbbaaaaabbababbbaabaabbabbaabbbbabaaabbababaaaabbbabaaabaabbbbab...

output:

3954

result:

ok 1 number(s): "3954"

Test #16:

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

input:

aaabbbbabaaabbabbaabbabbbbbbbaaabbaaaaabbbbbaaaabbbaaabbabbaabaabbbaabaababaabbbababbbbbbabbababbbbabaaababbbaaabbabbbaabbbbbbbbbbabbbbbabbabbbbabbbbbbbaabaaaaaabbbaaabaabaaaaabbabbaaabbababaaaaaababbbabaabbbaabaaabaabbabaaaaababaaabbaabaababbaaabaabbaabbbbaababbaabaaabababbbbbabbbbababbbbbbaabbabab...

output:

10033

result:

ok 1 number(s): "10033"

Test #17:

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

input:

aabbbbbabababbbababaaabaabbbbbbaaababaabaababbbbbaabaabababaabbbbbbaabbbababbbbbbbbbbabababbabbaaaabaaaaabbabbbabbaaaaababababaaabbbbbbbabbbbbbbbaaabbbaaababbaaaaaabaabbaababbbabaaabbbaabbabababbaaaababbbabbbabaaaaabbbabbbabbaaaabababbbbbbaabbbaaaabbabbabbabbbbbbbaabbbaabbbbabbbaabbbbbbabaaaabbaaabb...

output:

24882

result:

ok 1 number(s): "24882"

Test #18:

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

input:

bbabaaababbabbbbbbababaababaaabababaabbbaabbbabbababbbbbabbbbaaabbbbaaaaabbaaabbbabbbbaabaabbaaaabaababbbababbbbaaaaabaabaababbbbbabbbabbaaabbabbbbaabbabababababababaabbaabbaabbabaaaabaaabbbbbababbbbaaaaabaababbbbabaaaabababaaabaaaabbbbabbbbabaaaaaababbbbabaaabaaaabaaabaabaabaabaaabbabbbbabbababaaab...

output:

62283

result:

ok 1 number(s): "62283"

Test #19:

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

input:

bbbaabaababbaababbbbbbabbbbbbabaabbaaaaabbabbbbbabbabaabbbbaabaaababaaababbaaabababbabbababbbabaabbbabbabbabaabbbbaabaaabbaaabaaabbaaaaabaababbaabaaaabbbbababaababbabaaabababbaabbabbbabbababaaabbbbbabababbaabbbabaaabbaabaababaabbbaabbbaaabbbbabaabbbaaaabbbababaabbaaabaaababbbaabbbaabbbbbabababbababb...

output:

155673

result:

ok 1 number(s): "155673"

Test #20:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

121390

result:

ok 1 number(s): "121390"

Test #21:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

196413

result:

ok 1 number(s): "196413"

Test #22:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

121392

result:

ok 1 number(s): "121392"

Test #23:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

196416

result:

ok 1 number(s): "196416"

Test #24:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

121394

result:

ok 1 number(s): "121394"

Test #25:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

196419

result:

ok 1 number(s): "196419"

Test #26:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

196415

result:

ok 1 number(s): "196415"

Test #27:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

317806

result:

ok 1 number(s): "317806"

Test #28:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

196417

result:

ok 1 number(s): "196417"

Test #29:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

317809

result:

ok 1 number(s): "317809"

Test #30:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

196418

result:

ok 1 number(s): "196418"

Test #31:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

317811

result:

ok 1 number(s): "317811"

Test #32:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

242701

result:

ok 1 number(s): "242701"

Test #33:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

392698

result:

ok 1 number(s): "392698"

Test #34:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

242702

result:

ok 1 number(s): "242702"

Test #35:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

392700

result:

ok 1 number(s): "392700"

Test #36:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

242704

result:

ok 1 number(s): "242704"

Test #37:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

392703

result:

ok 1 number(s): "392703"

Test #38:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

242702

result:

ok 1 number(s): "242702"

Test #39:

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

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

242583

result:

ok 1 number(s): "242583"

Test #40:

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

input:

abaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaabbaaaaaaaaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaabaaaaaaabaaaaaaaaaaaaaaaaaaaaaaa...

output:

233809

result:

ok 1 number(s): "233809"

Test #41:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

392700

result:

ok 1 number(s): "392700"

Test #42:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

392441

result:

ok 1 number(s): "392441"

Test #43:

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

input:

bbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbabbbbbbbbbbabbbbbbbbbbbbbaabbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbaabbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbabbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbaababbbbbbababbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbbbb...

output:

367219

result:

ok 1 number(s): "367219"

Test #44:

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

input:

abaaaabbaabaababaababaabaabbaabaabbabbababbbbaaabbbbbaababbbababbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

output:

180

result:

ok 1 number(s): "180"

Test #45:

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

input:

abbaabbbababbaaabbabbabbbabbabbaabaaaabbbbabbbbbaabaabbaaabbababbbbbaaaaaaababbababbabaabbbbbbbbbbbb

output:

177

result:

ok 1 number(s): "177"

Test #46:

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

input:

aabaabbabaaaaaababbbbbaababaabaabbaaaabaabbababbbabaabaababbababbbbaababaabbaabbbbaabbababaaababbaaaaaabaababbbbababbbbabbababaaaaaabaaababaaababbabaaaabbbabbaababbabbbbbbaababbaabbbabaabaabaaababbabbabbabababaaabbbbaaabbbabbbabbabbbbabbabbbbababbaaabbaaabaababbaabbbaaabaabaaabbabbaabbbbbbabbbaaaabb...

output:

1673

result:

ok 1 number(s): "1673"

Test #47:

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

input:

baababaabaababaaabaabbbababbaaabbaabaaababbbbbaaaaababbbaaaaaaaabaaabbbaabbbbaabbabbabbbabaaaabbaabbaabbababbbbabbbaaabbbaabababababaabbbababaabbbbabbbbbaaaababaabbabbbabaaaabaaaaabaabaabbabbaabaaababbbabaaaabaaaabaaaaabbbbbbabbababaaababbbaabababbbbbbbbbababbbbbababbbabaaaabbabbbabbbabbbbaaaabaabab...

output:

1719

result:

ok 1 number(s): "1719"

Test #48:

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

input:

abbbbbbababaaabbaabbbbaaabbbababbaaabbabbbbaabbbabbbbabbbabbaabbabbbbabaaabbaabbbabbababaaaaabaabbababbbaabbabbbaaaababbbaabbbabaaababaabbabbaabbbabbabbbababbabababbaaaaaaabbabbbbbaabaabbbbaaaaabbaabaabbbbbaaabbbabbaaabbabbaaaaaaaaababbaabbaabbbbbbbbbababaaababababbabbbaabbbabbaabaabbbbbbbbbbbaabaaa...

output:

246836

result:

ok 1 number(s): "246836"

Test #49:

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

input:

aaaaaaabbbaaabbbabbbabbbababababbbbaaabbbbbabbabbbbbaabbaabababbabbaabbbbbbbabbbbabbbabaaababaaabaaaabaaaaabababaabaabaaaaababbbaabbaaabbbabaabbaaabbaabbaaabbbabaabbaaaabbabbbaababbababbbbbbaabbbaaaaabaaababaaaababbbabbaabaabbbbabbabbabbbbbbbababbaababaababbbbbaaabaaaabbaabaaabababbbbabaaabaaaababbb...

output:

246901

result:

ok 1 number(s): "246901"

Test #50:

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

input:

baabbbaaaabbbbbaababbabbaaaaaaaaabaaaabbaaabbabbbbbbbbbaaaaabbbbbababbbbbbbbbbbabbbbabaaabbbbbabbaabbbabababaabbaababbbababaaabbbababaaaaabaaaabababbabaabbbabbbbaabaaaababbaabbbbbabababaabbbbbabbbbbaaabaaababaababbabaabababbbbaabababbabbbabbabbbbababaabaaaabbbabbabaabaabbbabbbaabaabababaaaaaabbbabbb...

output:

246841

result:

ok 1 number(s): "246841"

Test #51:

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

input:

aabbbbaaabbaabaabaabbabbbaaaababaabaaaaababbabbaabbaababbbbabbaaaabbaaaaabaabbaabbbabaaababaabbbbbababbbaababababbbbbbaaaabbbabaaabbbabbbbaababbaabaabbaaababbbababaaabbbbbbaaaabbbaabaaabbbbbaabababaaaaababbabbaabbbbbabbabaabbaaabbbabababbabbababbabbbbbaaabbaaabaabaaabbbaabbbabbaabaaaababbbabbabbaaba...

output:

246720

result:

ok 1 number(s): "246720"

Test #52:

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

input:

baabbaabbbabbabbbbbababbbabbbaababbbabbbbbabbbbbbabbbbbbbabbbaabbbbbbbbbbbbbbbaaaabbbbbbabbbbbabaaabbbbbbbabbbabbbababbbbabbbaaabbbaabbbbbbbabbbbbaabbabbbabbbabababbaababbbbabbabbbbbabbbabbbbbbbbaaabbaababbbbbabbbbbbbbbbabbaabbabbbbbbbbbabbabbababbbabbbabbbabbbbbbbabbbbbbbbbabbbbbbbbbbbbbababbabbbaa...

output:

266491

result:

ok 1 number(s): "266491"

Test #53:

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

input:

bbbbbbbbbbbbbaababbbaababbbbbbbbbabbbbbbbbbbbbabbbbbabbbababbbaabbabbbbbbbbabbbbbabbbbabbbbbbbbbbbabbbbbbabbbbbbabbabaaabbbababbaabbbbbabbbbbbbabababbbbbbbbbabbbbabbabbbaabbbaabbbbabababbbbbabababbabbbbababbbabbabbbababbbbbbbbbababbbbbbbbbababbbbbbbbbbbabbabbbabbbbaabbbbabbbabbbbbbbabbbbbbbabbbbbbba...

output:

266645

result:

ok 1 number(s): "266645"

Test #54:

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

input:

bbbbbbbabbbbabbbbbbabbbaaabbabaabbabbbbbbbbabbbaaaabbbbabbbabababbbbbbbbbbbabbbaabbbbbbbabbbbbbbbbbbbbbabbbaabbbbababbbbbbbabbbaabbabbbabbbabbbaabbaabaabaabbbbaabbbabbbaabbbbabbbbbaabbbaaaaabbbbbbbbabbbbbbaabbbbbababbbabbbbbbbabbbbbbbabbbbbbbabbaababbbbbbbbbbbbabbabbaaaababbbbbabbababbbbabbbabbbbaba...

output:

266745

result:

ok 1 number(s): "266745"

Test #55:

score: 0
Accepted
time: 21ms
memory: 46740kb

input:

babbbbabbbababaababbbbaaaababbbbbbabbaabbbaaaabbbbbabbbbbaababbababbbabbbbbbbbbaabbbaabbabbbbbbbbbbbbbbbaababbbaaaaabbbabbababababbaababbbaaabbbbbbabaabbbabbbbbbababbabbabbabbbaaaabbaababbbabbbbaabbbbaabbbbbbbbbbbbaabbbabbbabbbabbbabbbbbbbbabaaabbabbbbbaababbababbbababbababbbbbbbbaabbababbaaaabbbbbb...

output:

282172

result:

ok 1 number(s): "282172"

Test #56:

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

input:

babbbbbaabbbbabbbbbbbbbbabbabbbbabbbbbbbbbaabbaabbbbbaababbbabbbbbbbbbbbbabbbbbabbbbabbabbabbbbabbabbababbbbbbbbabbbbabbbbbbbbbbbbaababaabbbbbbbbbbbbaabbaabbabbbaaaabbbabababbbbbbbbbabbbbbabbbababbbbbbabbbbbbbbabbbbaaaabbbbaababbbbbbbbabababbbbbbabbbbbabbbbbbbaababaaababbbabbabbababbbabbbbbbbaabbbbb...

output:

305384

result:

ok 1 number(s): "305384"

Test #57:

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

input:

babbbaaabbaabbbbbbabbbaaabbabaabbbbbbbbbbbbbbabbbbbbbaabbbbbbbbbbbbbbbbbbbbbbbbababbabbbbbbbabbbbbbbbbbbbabbbabbbbbbbabbbbabbbbabbbbbbaabbbbbbbabababbbbabbbbbabaaaabbbbabbbbbabbabbbbbbabbbbbabbabbabbbbbbbabbababbbbbbbababbbbbabbbbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbabbababbbbbabbbbbbbbbbbbba...

output:

320836

result:

ok 1 number(s): "320836"

Test #58:

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

input:

babbbabbbabbbaaabbbbababbabbbaababbbbbbaabbbabbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbabbbbababaabbbabbbbbbbbbbbaabbbbbbabbbbbbbbbbbbbbabbbbbbbbbabbbbbbbabbbbbbbbbbbbbabbbbbbbbabbbbbbbbabbbbbbbbaabbbbbbbbbabbbbbbbbbababbbbbbaabbbbbabbbbbbbbbbbaabbbbbbbbbbbbbbabbbbbabbbbbaabbbbbabbbbbbabbbbbbbababbbbb...

output:

332069

result:

ok 1 number(s): "332069"

Test #59:

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

input:

bbbbbabbbabbbbbbbabbbaabbabbbbabbbaababbababbbbbabbbabaabbabbbbbbbababbbbbbbabbbbababaabbbbaababaabbabbabbbbaabbabaaabaabbbbbbbbbbaabaabbbbabaabaaabbbbbbabaabababbbabbbabbbabbbbbbbbabbbbabbbabaaababbaaabaaabbbbbbaabbbbabbbabbababababbaababbaabbbabbbbabaaabbaaabaabbbbbbaabbbabbababbaabbbbabbabbbabbbb...

output:

281875

result:

ok 1 number(s): "281875"

Test #60:

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

input:

bbabbbbbbabbbbbbbbbbbbbbbbbbabbbaabbbabbbbbbbaabaababbbbbaaabbabbbbabbbbaabbbbbabbbbbbbaabbbabbbbbbabbbabbabbabaaabbabaabbbaabbbbbbbbbbaabababaaabbbbbaabbbbabbbbbabbababbabababbbabbbabbbbbabbabbbbaabaabbbbabaabbabbabbbbbbababbbbbabbbbbabaabbbbbbbbabbbabbbbabbbbbbbabbabbabbbbbaababbbbabbbbbbbbbabbbbb...

output:

305753

result:

ok 1 number(s): "305753"

Test #61:

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

input:

babbbabbbabababaabbbabbabbbbbbababbbbbbbbbbabbbbbabababbbbbbabbbbbbbbbbbbbbbabbbbbbbbabbbbababbabbabbaaabaabbbbbbbbabbbbbbbbaabbabbababbbbbbbbbbbabaabbbbbbbbbbbabbbbbababaabbbaabbbbbbbbbabbbbababbaabaababbbbababbbbbabbbbbabbbbbbbbabbbbbbbbabbbaabbbbbbbbbbbbbabbbbbabbbbbabbbababbbbbbbbbbbbbaabbbbbbab...

output:

321150

result:

ok 1 number(s): "321150"

Test #62:

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

input:

bbbbbabbabbbabbbbbbbbabbbbbbabbbbabbbabbbbbbbbbbbbabbbababbbbbbbbbbbbbbbbbbbbbbabbbbbbabbbbabbbbbabbbbbabbbbbbabbbababbbbbbbbbabbbbababaabbbbbbbbbbbbabbbbbbbbbbbabbbbbbababbbbbbbbabbbbabbbbbbbbabbbbbbabbbbabbbabbbbbabbbbbbbbbbbbbbbbabbbbbbabbbababbbbbabbbbabbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbabbba...

output:

331900

result:

ok 1 number(s): "331900"

Test #63:

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

input:

bbbabbbbbbbabbbbbabbababaabbabbbbabbbbbbbbabbbabbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbabbbbbbabbbbabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbabbbbbbabbbbbbbbbabbbbbbbbbbbbababbbbbbbbbbbbaabbbbbbababbbbbbbbbbbbabbbabbbbbbbbbbbbbaabbbbbbbbbbbbabbbabbbbabbbabbbbbbbbbbabbbbabbbb...

output:

339945

result:

ok 1 number(s): "339945"

Test #64:

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

input:

bbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbbbbbbabbbababbbbabbbabbbbbbbbbbbabbbbbbbbbbbabbbaabababbbbbbabbbbbbbbbbbbbbabbbbbbbbbbbbabbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbabbbbbbbababbbbbabbabbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbaabbbbbbbbabbbbbbbbba...

output:

346933

result:

ok 1 number(s): "346933"

Test #65:

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

input:

abaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaa...

output:

150000

result:

ok 1 number(s): "150000"

Test #66:

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

input:

babaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaaba...

output:

150000

result:

ok 1 number(s): "150000"

Test #67:

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

input:

ababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaabab...

output:

150001

result:

ok 1 number(s): "150001"

Test #68:

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

input:

baababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaababaabababaabaababaababaabaababaabaababaababaa...

output:

151000

result:

ok 1 number(s): "151000"

Test #69:

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

input:

baabaabaaaabaaaaaabbababaaaaabaabbaaaabbaabaababaaaabbaababaabbabaababbaabaababbabaaababaaaabbaabababbaabaaabbabaababababaaabaabaaababaaababaabababaabaababaababaababaabaabaababbaabaaabaabaabbaababbababaaabaaabbaabaabaabaaaabbaaaaababbabababaabaaabaabaabababababbabaaaabaababaabaabababababababaabababa...

output:

199864

result:

ok 1 number(s): "199864"

Test #70:

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

input:

bbaabaababaaabababaababaabababaababababbabababababaabaabbaabababababaaabaaaaabaaababaaabaabababaabaababaaaababaaaabbaaaabaaabbaaabbabababaabbaabaabbaabababaabbaaabbabaabaabababaabbaabaaaabaabababaabaababaabaaabbaababaaaabababababaabaaaababaabaababbabaababaabababaabaababaabababababbababaaabaabaababab...

output:

196473

result:

ok 1 number(s): "196473"

Test #71:

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

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

346417

result:

ok 1 number(s): "346417"

Extra Test:

score: 0
Extra Test Passed