QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#121622#4273. Good Gamebashkort#9 10ms4216kbC++202.6kb2023-07-08 15:47:292024-07-04 00:31:23

Judging History

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

  • [2024-07-04 00:31:23]
  • 评测
  • 测评结果:9
  • 用时:10ms
  • 内存:4216kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-08 15:47:29]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector dp(n, vector<int>(n));

    for (int l = n - 1; l >= 0; --l) {
        for (int r = l + 1; r < n; ++r) {
            if (r <= l + 2 && s[l] == s[r] && s[l] == s[l + r >> 1]) {
                dp[l][r] = -1;
            } else {
                for (int mid = l + 1, cnt = 0; mid + 1 < r && ++cnt <= 500; ++mid) {
                    if (dp[l][mid] && dp[mid + 1][r]) {
                        dp[l][r] = mid;
                        break;
                    }
                }
                for (int mid = r - 1, cnt = 0; mid >= l && ++cnt <= 500; --mid) {
                    if (dp[l][mid] && dp[mid + 1][r]) {
                        dp[l][r] = mid;
                        break;
                    }
                }
                if (!dp[l][r] && s[l] == s[r]) {
                    for (int mid = l + 1, cnt = 0; mid < r && cnt < 1000; ++mid) {
                        if (s[mid] == s[l] && (l + 1 > mid - 1 ? true : dp[l + 1][mid - 1]) && (mid + 1 > r - 1 ? true : dp[mid + 1][r - 1])) {
                            dp[l][r] = ~mid;
                            break;
                        }
                        cnt += s[mid] == s[l];
                    }
                    if (dp[l + 1][r - 1]) {
                        dp[l][r] = r;
                    }
                }
            }
        }
    }

    if (!dp[0][n - 1]) {
        cout << "-1\n";
        return 0;
    }

    vector<pair<int, int>> ans;

    auto dfs = [&](auto dfs, int l, int r, int del) -> int {
        if (l > r) {
            return 0;
        }
        if (l + 2 >= r) {
            ans.push_back({l - del, r - l + 1});
            return r - l + 1;
        }
        if (dp[l][r] >= 0) {
            int mid = dp[l][r];
            if (mid < r) {
                del += dfs(dfs, l, mid, del);
                dfs(dfs, mid + 1, r, del);
            } else {
                dfs(dfs, l + 1, r - 1, del);
                ans.push_back({l - del, 2});
            }
        } else {
            int mid = ~dp[l][r];
            int d = del;
            del += dfs(dfs, l + 1, mid - 1, del);
            del += dfs(dfs, mid + 1, r - 1, del);
            ans.push_back({l - d, 3});
        }
        return r - l + 1;
    };

    dfs(dfs, 0, n - 1, 0);

    cout << size(ans) << '\n';

    for (auto [l, r] : ans) {
        cout << l + 1 << " " << r << '\n';
    }

    return 0;
}

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

9
ABAABBBAA

output:

4
3 2
2 2
2 2
1 3

result:

ok good solution!

Test #2:

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

input:

13
ABABBABABBABA

output:

6
4 2
3 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #3:

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

input:

15
AABABAABABAABAB

output:

7
1 2
4 2
3 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #4:

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

input:

15
ABAABBBABAABBAB

output:

7
3 2
2 2
2 2
1 2
4 2
2 3
1 2

result:

ok good solution!

Test #5:

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

input:

1
B

output:

-1

result:

ok no solution

Test #6:

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

input:

2
BB

output:

1
1 2

result:

ok good solution!

Test #7:

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

input:

7
AAAABBB

output:

3
1 2
1 2
1 3

result:

ok good solution!

Test #8:

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

input:

11
BBBBBBAAAAA

output:

5
1 2
1 2
1 2
1 3
1 2

result:

ok good solution!

Test #9:

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

input:

2
AB

output:

-1

result:

ok no solution

Test #10:

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

input:

14
BAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #11:

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

input:

14
ABBABAABBABBAB

output:

7
2 2
1 2
2 2
1 2
3 2
2 2
1 2

result:

ok good solution!

Test #12:

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

input:

15
BAABABABBABBAAB

output:

6
2 2
6 2
5 2
4 3
3 3
1 3

result:

ok good solution!

Test #13:

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

input:

14
BABBBBBBBBBBAB

output:

7
3 2
3 2
3 2
3 2
3 2
2 2
1 2

result:

ok good solution!

Test #14:

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

input:

15
BABAAAAAAAAABAB

output:

7
4 3
4 2
4 2
4 2
3 2
2 2
1 2

result:

ok good solution!

Test #15:

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

input:

14
BBBABAAAAAAABA

output:

6
1 3
3 3
3 2
3 2
2 2
1 2

result:

ok good solution!

Test #16:

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

input:

15
AAAABABAAAAABAB

output:

7
1 2
1 2
4 3
4 2
3 2
2 2
1 2

result:

ok good solution!

Test #17:

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

input:

14
BAAABABAAAABAB

output:

6
2 3
5 2
5 2
4 2
3 2
1 3

result:

ok good solution!

Test #18:

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

input:

15
ABAAAABABBBBABA

output:

7
3 2
3 2
5 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #19:

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

input:

14
BABAAABAAAABAB

output:

6
4 3
5 2
5 2
3 3
2 2
1 2

result:

ok good solution!

Test #20:

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

input:

15
BABBABABBBBBBAB

output:

7
3 2
2 2
4 2
4 2
4 2
3 2
1 3

result:

ok good solution!

Test #21:

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

input:

14
BABAAAABABBBAB

output:

6
4 2
4 2
3 2
4 3
2 3
1 2

result:

ok good solution!

Test #22:

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

input:

15
BABAAAAAABABAAB

output:

7
4 2
4 2
4 2
3 2
2 2
3 2
1 3

result:

ok good solution!

Test #23:

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

input:

14
BABBBBBABAAAAA

output:

6
3 3
3 2
2 2
1 2
1 3
1 2

result:

ok good solution!

Test #24:

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

input:

15
BABAAAABABAAAAA

output:

7
4 2
4 2
3 2
2 2
1 2
1 3
1 2

result:

ok good solution!

Test #25:

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

input:

15
BAABABAABAABBAA

output:

7
2 2
1 2
3 2
2 2
1 3
1 2
1 2

result:

ok good solution!

Test #26:

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

input:

15
AABAABBAABAABAB

output:

7
1 2
2 2
1 2
5 2
4 2
2 3
1 2

result:

ok good solution!

Test #27:

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

input:

15
AABABBABAABBABB

output:

7
5 2
4 2
3 2
1 3
2 2
1 2
1 2

result:

ok good solution!

Test #28:

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

input:

15
BAABBABBAABABBA

output:

7
4 2
2 3
1 2
2 2
1 2
2 2
1 2

result:

ok good solution!

Test #29:

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

input:

15
BBAABBABABABBAA

output:

-1

result:

ok no solution

Test #30:

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

input:

15
ABABBAABBAABBAB

output:

-1

result:

ok no solution

Test #31:

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

input:

14
AAABAAAAABAAAB

output:

5
1 3
2 3
2 2
3 3
1 3

result:

ok good solution!

Test #32:

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

input:

15
ABBBBABBBBBABBB

output:

6
2 2
2 2
3 3
3 2
1 3
1 3

result:

ok good solution!

Test #33:

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

input:

14
BBBBABBABAAABA

output:

6
1 2
1 2
2 2
4 3
3 2
1 3

result:

ok good solution!

Test #34:

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

input:

15
AAAAABABBBABBAB

output:

6
1 3
1 2
3 3
4 2
2 3
1 2

result:

ok good solution!

Test #35:

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

input:

14
AABABBBBABAAAB

output:

6
1 2
3 2
3 2
2 2
3 3
1 3

result:

ok good solution!

Test #36:

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

input:

15
BAABAAAABABBBBA

output:

7
2 2
3 2
3 2
1 3
2 2
2 2
1 2

result:

ok good solution!

Test #37:

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

input:

14
ABBBABAAABAAAB

output:

5
2 3
1 2
2 3
3 3
1 3

result:

ok good solution!

Test #38:

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

input:

15
BAAABABBBBABAAA

output:

6
2 3
4 2
4 2
3 2
1 3
1 3

result:

ok good solution!

Test #39:

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

input:

14
BABBABBBBABAAA

output:

6
3 2
4 2
4 2
2 3
1 2
1 3

result:

ok good solution!

Test #40:

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

input:

15
ABAAABABBBABBBB

output:

6
3 3
2 2
3 3
1 3
1 2
1 2

result:

ok good solution!

Test #41:

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

input:

14
AABABABBAABBAA

output:

-1

result:

ok no solution

Test #42:

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

input:

15
AABBBABABAABBAA

output:

-1

result:

ok no solution

Test #43:

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

input:

14
AABBAABABABBAA

output:

-1

result:

ok no solution

Test #44:

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

input:

15
BBBAABBAABABABB

output:

-1

result:

ok no solution

Test #45:

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

input:

15
BABABBBBAABBAAA

output:

-1

result:

ok no solution

Test #46:

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

input:

15
BBBABABAABBBAAA

output:

-1

result:

ok no solution

Test #47:

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

input:

15
AAABBBBAABABABB

output:

-1

result:

ok no solution

Test #48:

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

input:

15
AAAAABBAABBABAB

output:

-1

result:

ok no solution

Test #49:

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

input:

15
BAAAABBAABBBABA

output:

-1

result:

ok no solution

Test #50:

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

input:

15
BABAAABBBAAABBA

output:

-1

result:

ok no solution

Subtask #2:

score: 6
Accepted

Test #51:

score: 6
Accepted
time: 3ms
memory: 3732kb

input:

299
ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #52:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #53:

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

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
96 2
96 2
96 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
97 2
97 2
97 2
96 2
95 2
94 2
93 2
92 2
9...

result:

ok good solution!

Test #54:

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

input:

299
BBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
1 2
1 2
1 2
96 3
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
97 3
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2...

result:

ok good solution!

Test #55:

score: 0
Accepted
time: 10ms
memory: 3980kb

input:

297
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
74 2
73 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
1...

result:

ok good solution!

Test #56:

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

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
58 3
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
88 3
...

result:

ok good solution!

Test #57:

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

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

148
59 3
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
87 3
86 2
...

result:

ok good solution!

Test #58:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBAAAABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
3...

result:

ok good solution!

Test #59:

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

input:

298
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

output:

149
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
...

result:

ok good solution!

Test #60:

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

input:

298
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #61:

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

input:

297
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

148
1 3
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
...

result:

ok good solution!

Test #62:

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

input:

300
AAAABBBBAAAABBBBBBAABBAABBBBAAAAABBBBBAAAABBBBAAAABBBBBBAABBBAAAABBBBAAAABBBBBBAAAAABBAAABBAAABBBBBAAAABBBBAAABBBBAAAAAABBBBAABBAAAABBBBAAABBBBBAAABBBBBAAAABBAAABBBAABBBAAAABBBAAAAAABBBBBBAAABBAAAAAABBBBBAAAAAABBBBAAAAABBBBAAAABBBBBBAAABBBBAAAAAAABBAAAAAAABBBBBAAAABBBBAAAAABBBAAAAABBBAAAABBBBAAA...

output:

146
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 3
2 2
1 2
1 2
2 2
2 2
1 2
1 2
2 2
2 2
2 2
1 2
2 3
1 2
1 2
2 2
2 2
1 2
1 2
2 2
2 2
2 2
1 2
1 2
1 2
1 2
1 2
2 2
1 2
1 2
1 2
1 2
2 2
2 2
1 2
1 2
2 3
1 2
1 2
2 2
2 2
2 2
1 2
1 2
2 2
1 2
2 2
2 2
1 2
1 2
2 3
1 2
1 2
1 2
1 2
2 3
2 2
1 2
...

result:

ok good solution!

Test #63:

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

input:

299
BBBBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABAAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABA...

output:

148
1 3
1 2
1 2
1 2
1 2
88 2
88 2
88 2
88 2
88 2
125 3
125 2
125 2
125 2
125 2
125 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
87 3...

result:

ok good solution!

Test #64:

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

input:

299
BABABABABABABABBBBBBBBBBABABABABABABABABABABABABABBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
15 3
15 2
15 2
15 2
41 2
41 2
41 2
41 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
19 2
19 2
19 2
19 2
19 2
18 2
84 2
84 2
84 2
84 2
84 2
83 2
...

result:

ok good solution!

Test #65:

score: 0
Accepted
time: 5ms
memory: 4008kb

input:

298
ABABABABABABABABABAAAAABABABABABABABABABAAAABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAABABABABABABABBBBBBABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABBBBBBABAAAAAABABABABABABABABBBBBBBABABABBBBBBABABABABABABABABABABABABABABABABABABABABABA

output:

147
19 2
19 2
37 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
49 3
49 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
27 3
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 ...

result:

ok good solution!

Test #66:

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

input:

298
BABABABABABABABAAAAABABABABABABABABABABABABABAAAAAABABABABABABABABABABABABABABABABABABAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABAAAAAAAAAABBBBABABABAAAAAAAABABABABABABABAAAABABABABABABBBBBABABABABABABABABBBBABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

146
16 2
16 2
42 2
42 2
42 2
41 2
40 2
39 2
71 2
71 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
38 3
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
2...

result:

ok good solution!

Test #67:

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

input:

297
BABABABABABABABABABABABAAAAAAABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABAABBBBBBABAABABABABABABAAAAABABABABABBBBBBBABABABABABABABAAAABABABABAAAABABABBABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABBBBBABABABAABBBBABABABABABABABAB

output:

144
24 3
24 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
13 3
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
13 3
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
4 3
4 2
7 2
6 2
5 2
4 2
2 3
1 2
7 3
7 2
6 2
...

result:

ok good solution!

Test #68:

score: 0
Accepted
time: 5ms
memory: 4132kb

input:

297
BABABABABABABABABABABABABABABABABABABABAABABABABABBBBABABABAAAAAABABABABABABABBBBBABABABABABAAAABABABABABABABABABABABABABBABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABAAAAABABAAAABABAAAAAAABABABABABABAAAAAAAABABABABABAAABABABABABABABABABABABABABABABABBBABABABABABABABBA

output:

143
40 2
39 2
38 2
37 2
36 2
35 2
38 2
38 2
37 2
36 2
34 3
33 2
32 2
31 2
30 3
30 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 3
17 2
28 3
61 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
53 3
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
3...

result:

ok good solution!

Test #69:

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

input:

299
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
149 3
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
10...

result:

ok good solution!

Test #70:

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

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
150 2
149 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
10...

result:

ok good solution!

Test #71:

score: 0
Accepted
time: 10ms
memory: 4156kb

input:

300
AABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
1 2
148 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 ...

result:

ok good solution!

Test #72:

score: 0
Accepted
time: 10ms
memory: 3992kb

input:

300
ABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
2 2
1 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
...

result:

ok good solution!

Test #73:

score: 0
Accepted
time: 10ms
memory: 3928kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
61 3
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
...

result:

ok good solution!

Test #74:

score: 0
Accepted
time: 10ms
memory: 4028kb

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABAB...

output:

150
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 ...

result:

ok good solution!

Test #75:

score: 0
Accepted
time: 10ms
memory: 3964kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99...

result:

ok good solution!

Test #76:

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

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
148 3
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99...

result:

ok good solution!

Test #77:

score: 0
Accepted
time: 10ms
memory: 4024kb

input:

299
BAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
2 2
2 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
...

result:

ok good solution!

Test #78:

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

input:

299
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
62 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 ...

result:

ok good solution!

Test #79:

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

input:

297
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAB

output:

148
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99 2
98 ...

result:

ok good solution!

Test #80:

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

input:

297
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99 2
98 ...

result:

ok good solution!

Test #81:

score: 0
Accepted
time: 10ms
memory: 3928kb

input:

297
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
147 2
148 2
146 3
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100 2
99...

result:

ok good solution!

Test #82:

score: 0
Accepted
time: 10ms
memory: 3988kb

input:

298
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
87 2
148 3
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 2
134 2
133 2
132 2
131 2
130 2
129 2
128 2
127 2
126 2
125 2
124 2
123 2
122 2
121 2
120 2
119 2
118 2
117 2
116 2
115 2
114 2
113 2
112 2
111 2
110 2
109 2
108 2
107 2
106 2
105 2
104 2
103 2
102 2
101 2
100...

result:

ok good solution!

Test #83:

score: 0
Accepted
time: 10ms
memory: 4144kb

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
88 3
87 2
86 2
85 2
84 2
83 2
82 2
81 2
80 2
79 2
78 2
77 2
76 2
75 2
74 2
73 2
72 2
71 2
70 2
69 2
68 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
2...

result:

ok good solution!

Test #84:

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

input:

300
ABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABAABBAABBAABBAABBAABBAAABBAABBAAABBAABBAAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBBAABBAABBAABBAABB...

output:

106
2 2
1 2
96 2
95 2
94 3
93 3
92 3
91 3
90 3
89 3
88 3
87 3
86 3
85 3
84 2
84 2
83 3
82 3
81 3
80 2
80 2
79 3
78 3
77 3
76 2
76 2
75 3
74 3
73 3
72 3
71 3
70 3
69 3
68 3
67 3
66 3
65 2
65 2
64 3
63 3
62 3
61 3
60 3
59 3
58 3
57 3
56 3
55 3
54 3
53 3
52 3
51 3
50 3
49 3
48 3
47 3
46 3
45 3
44 3
43 ...

result:

ok good solution!

Test #85:

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

input:

299
BBABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

105
1 2
2 2
1 2
30 2
37 2
54 2
147 2
170 2
186 2
185 2
183 3
181 3
179 3
177 3
175 3
173 3
171 3
170 2
168 3
166 3
164 3
162 3
160 3
158 3
156 3
154 3
152 3
150 3
148 3
147 2
145 3
143 3
141 3
139 3
137 3
135 3
133 3
131 3
129 3
127 3
125 3
123 3
121 3
119 3
117 3
115 3
113 3
111 3
109 3
107 3
105 3...

result:

ok good solution!

Test #86:

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

input:

299
AABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBA...

output:

134
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 3
32 3
31 3
30 3
29 3
28 3
27 3
26 3
25 3
24 3
23 3
22 3
21 3
20 3
19 3
18 3
17 3
16 3
15 3
14 3
13 3
12 3
11 2
11 2
10 3
9...

result:

ok good solution!

Test #87:

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

input:

299
BAABBBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAAABBAABBABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABAB...

output:

132
2 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 3
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 3
1 2
2 2
1 2
2 2
1 2
2 3
1 2
4 2
2 3
1 2
64 2
62 3
60 3
58 3
56 3
54 3
52...

result:

ok good solution!

Test #88:

score: 0
Accepted
time: 5ms
memory: 3992kb

input:

300
AAABBAABBAABBAABBAABBAABBAABBAABBBAAABBAABBAABBAABBAAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

105
1 3
29 2
30 2
45 2
64 2
81 2
185 2
184 2
182 3
180 3
178 3
176 3
174 3
172 3
170 3
168 3
166 3
164 3
162 3
160 3
158 3
156 3
154 3
152 3
150 3
148 3
146 3
144 3
142 3
140 3
138 3
136 3
134 3
132 3
130 3
128 3
126 3
124 3
122 3
120 3
118 3
116 3
114 3
112 3
110 3
108 3
106 3
104 3
102 3
100 3
98 ...

result:

ok good solution!

Test #89:

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

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABAABBAABBAABBAABBBAABBAABBAABBAAABBAABBAABBAAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABB...

output:

106
96 2
95 2
94 3
93 3
92 3
91 3
90 3
89 3
88 3
87 2
87 2
86 3
85 3
84 3
83 3
82 3
81 3
80 2
80 2
79 3
78 3
77 3
76 3
75 3
74 2
74 2
73 3
72 3
71 2
71 2
70 3
69 3
68 3
67 3
66 3
65 3
64 3
63 3
62 3
61 3
60 3
59 3
58 3
57 3
56 3
55 3
54 3
53 3
52 3
51 3
50 3
49 3
48 3
47 3
46 3
45 3
44 3
43 3
42 2
4...

result:

ok good solution!

Test #90:

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

input:

299
BBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBBAABAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABB...

output:

123
31 2
52 2
78 2
93 2
91 3
89 3
87 3
85 3
83 3
81 3
79 3
78 2
76 3
74 3
72 3
70 3
68 3
66 3
64 3
62 3
60 3
58 3
56 3
55 2
53 3
52 2
50 3
48 3
46 3
44 3
42 3
40 3
38 3
36 3
34 3
32 3
31 2
29 3
27 3
25 3
23 3
21 3
19 3
17 3
15 3
13 3
11 3
9 3
7 3
5 3
3 3
1 3
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
2...

result:

ok good solution!

Test #91:

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

input:

300
ABABABABABABABABABABABABABABAABABABABABABABABABABABBAABBBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABBAABBAABBAABBAABBAAABBAAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABAB...

output:

124
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 3
7 3
6 2
6 2
5 3
4 3
3 3
2 3
1 3
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
2 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
...

result:

ok good solution!

Test #92:

score: 0
Accepted
time: 10ms
memory: 3912kb

input:

298
ABABABABABABABABABABABABABABABABAABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB

output:

148
33 2
48 3
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
32 3
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
98 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
...

result:

ok good solution!

Test #93:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
49 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
96 3
96 2
95 2
94 2
93 2
92 2
91 2
90 2
89 2
88 2
87 2
...

result:

ok good solution!

Test #94:

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

input:

298
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB

output:

147
59 3
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
12 3
...

result:

ok good solution!

Test #95:

score: 0
Accepted
time: 10ms
memory: 3916kb

input:

300
ABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
30 3
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
60 3
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2...

result:

ok good solution!

Test #96:

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

input:

299
AABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #97:

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

input:

300
AABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAA...

output:

-1

result:

ok no solution

Test #98:

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

input:

299
BBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #99:

score: 0
Accepted
time: 5ms
memory: 3964kb

input:

300
BBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #100:

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

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAA...

output:

-1

result:

ok no solution

Test #101:

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

input:

300
BBAABBBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAA...

output:

-1

result:

ok no solution

Subtask #3:

score: 0
Time Limit Exceeded

Test #102:

score: 0
Time Limit Exceeded

input:

5998
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #153:

score: 0
Time Limit Exceeded

input:

999997
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:


result: