QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627704#4273. Good Gamechenxinyang2006#9 30ms4824kbC++202.3kb2024-10-10 16:49:482024-10-10 16:49:49

Judging History

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

  • [2024-10-10 16:49:49]
  • 评测
  • 测评结果:9
  • 用时:30ms
  • 内存:4824kb
  • [2024-10-10 16:49:48]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int n;
char s[305];

int dp[305][305],opt[305][305];
vector <pii> solve(int l,int r){
	if(l > r) return vector<pii>();
	vector <pii> res,temp;
	if(s[l] == s[r] && dp[l + 1][r - 1]){
		res = solve(l + 1,r - 1);
		for(pii &I:res){
			I.first++;
			I.second++;
		}
		res.eb(1,2);
		return res;
	}
	if(opt[l][r] < 0){
		res = solve(l,-opt[l][r]);
		temp = solve(-opt[l][r] + 1,r);
		for(pii &I:temp) res.eb(I);
		return res;
	}
	res = solve(l + 1,opt[l][r] - 1);
	temp = solve(opt[l][r] + 1,r - 1);
	for(pii &I:res){
		I.first++;
		I.second++;
	}
	for(pii &I:temp){
		I.first += 2;
		I.second += 2;
		res.eb(I);
	}
	res.eb(1,3);
	return res;
}

int main(){
//	freopen("test.in","r",stdin);
	scanf("%d",&n);
	scanf("%s",s + 1);
	rep(i,1,n + 1) dp[i][i - 1] = 1;
	rep(len,1,n){
		rep(i,1,n){
			int j = i + len - 1;
			rep(k,i + 1,j - 1){
				if(dp[i + 1][k - 1] && dp[k + 1][j - 1] && s[i] == s[k] && s[k] == s[j]){
					dp[i][j] = 1;
					opt[i][j] = k;
				}
			}
			rep(k,i,j - 1){
				if(dp[i][k] && dp[k + 1][j]){
					dp[i][j] = 1;
					opt[i][j] = -k;
				}
			}
			if(s[i] == s[j] && dp[i + 1][j - 1]) dp[i][j] = 1;
//			if(dp[i][j]) printf("[%d,%d]\n",i,j);
		}
	}
	if(!dp[1][n]){
		printf("-1\n");
		return 0;
	} 
	vector <pii> output = solve(1,n);
	printf("%d\n",SZ(output));
	for(pii I:output) printf("%d %d\n",I.first,I.second - I.first + 1);
	return 0;
}

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

9
ABAABBBAA

output:

4
3 2
3 2
2 2
1 3

result:

ok good solution!

Test #2:

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

input:

13
ABABBABABBABA

output:

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

result:

ok good solution!

Test #3:

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

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: 3
Accepted
time: 0ms
memory: 4108kb

input:

15
ABAABBBABAABBAB

output:

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

result:

ok good solution!

Test #5:

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

input:

1
B

output:

-1

result:

ok no solution

Test #6:

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

input:

2
BB

output:

1
1 2

result:

ok good solution!

Test #7:

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

input:

7
AAAABBB

output:

3
2 2
1 2
1 3

result:

ok good solution!

Test #8:

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

input:

11
BBBBBBAAAAA

output:

5
3 2
2 2
1 2
1 3
1 2

result:

ok good solution!

Test #9:

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

input:

2
AB

output:

-1

result:

ok no solution

Test #10:

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

input:

14
BAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #11:

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

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: 3
Accepted
time: 0ms
memory: 3816kb

input:

15
BAABABABBABBAAB

output:

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

result:

ok good solution!

Test #13:

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

input:

14
BABBBBBBBBBBAB

output:

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

result:

ok good solution!

Test #14:

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

input:

15
BABAAAAAAAAABAB

output:

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

result:

ok good solution!

Test #15:

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

input:

14
BBBABAAAAAAABA

output:

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

result:

ok good solution!

Test #16:

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

input:

15
AAAABABAAAAABAB

output:

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

result:

ok good solution!

Test #17:

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

input:

14
BAAABABAAAABAB

output:

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

result:

ok good solution!

Test #18:

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

input:

15
ABAAAABABBBBABA

output:

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

result:

ok good solution!

Test #19:

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

input:

14
BABAAABAAAABAB

output:

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

result:

ok good solution!

Test #20:

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

input:

15
BABBABABBBBBBAB

output:

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

result:

ok good solution!

Test #21:

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

input:

14
BABAAAABABBBAB

output:

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

result:

ok good solution!

Test #22:

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

input:

15
BABAAAAAABABAAB

output:

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

result:

ok good solution!

Test #23:

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

input:

14
BABBBBBABAAAAA

output:

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

result:

ok good solution!

Test #24:

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

input:

15
BABAAAABABAAAAA

output:

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

result:

ok good solution!

Test #25:

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

input:

15
BAABABAABAABBAA

output:

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

result:

ok good solution!

Test #26:

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

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: 3
Accepted
time: 0ms
memory: 3812kb

input:

15
AABABBABAABBABB

output:

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

result:

ok good solution!

Test #28:

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

input:

15
BAABBABBAABABBA

output:

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

result:

ok good solution!

Test #29:

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

input:

15
BBAABBABABABBAA

output:

-1

result:

ok no solution

Test #30:

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

input:

15
ABABBAABBAABBAB

output:

-1

result:

ok no solution

Test #31:

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

input:

14
AAABAAAAABAAAB

output:

5
1 3
3 3
2 2
3 3
1 3

result:

ok good solution!

Test #32:

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

input:

15
ABBBBABBBBBABBB

output:

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

result:

ok good solution!

Test #33:

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

input:

14
BBBBABBABAAABA

output:

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

result:

ok good solution!

Test #34:

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

input:

15
AAAAABABBBABBAB

output:

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

result:

ok good solution!

Test #35:

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

input:

14
AABABBBBABAAAB

output:

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

result:

ok good solution!

Test #36:

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

input:

15
BAABAAAABABBBBA

output:

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

result:

ok good solution!

Test #37:

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

input:

14
ABBBABAAABAAAB

output:

5
2 3
1 2
2 3
3 3
1 3

result:

ok good solution!

Test #38:

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

input:

15
BAAABABBBBABAAA

output:

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

result:

ok good solution!

Test #39:

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

input:

14
BABBABBBBABAAA

output:

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

result:

ok good solution!

Test #40:

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

input:

15
ABAAABABBBABBBB

output:

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

result:

ok good solution!

Test #41:

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

input:

14
AABABABBAABBAA

output:

-1

result:

ok no solution

Test #42:

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

input:

15
AABBBABABAABBAA

output:

-1

result:

ok no solution

Test #43:

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

input:

14
AABBAABABABBAA

output:

-1

result:

ok no solution

Test #44:

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

input:

15
BBBAABBAABABABB

output:

-1

result:

ok no solution

Test #45:

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

input:

15
BABABBBBAABBAAA

output:

-1

result:

ok no solution

Test #46:

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

input:

15
BBBABABAABBBAAA

output:

-1

result:

ok no solution

Test #47:

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

input:

15
AAABBBBAABABABB

output:

-1

result:

ok no solution

Test #48:

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

input:

15
AAAAABBAABBABAB

output:

-1

result:

ok no solution

Test #49:

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

input:

15
BAAAABBAABBBABA

output:

-1

result:

ok no solution

Test #50:

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

input:

15
BABAAABBBAAABBA

output:

-1

result:

ok no solution

Subtask #2:

score: 6
Accepted

Test #51:

score: 6
Accepted
time: 25ms
memory: 4352kb

input:

299
ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #52:

score: 6
Accepted
time: 27ms
memory: 4432kb

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #53:

score: 6
Accepted
time: 23ms
memory: 4380kb

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
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 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
99 2
98 2
97 2
96 2
95 2
94 2
93 2
92 2
9...

result:

ok good solution!

Test #54:

score: 6
Accepted
time: 19ms
memory: 4332kb

input:

299
BBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
3 2
2 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
98 3
97 2
96 2
95 2
94 2
93 2
92 2
91 2
90 2...

result:

ok good solution!

Test #55:

score: 6
Accepted
time: 21ms
memory: 4168kb

input:

297
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
74 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
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: 6
Accepted
time: 22ms
memory: 4180kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
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
88 3
...

result:

ok good solution!

Test #57:

score: 6
Accepted
time: 22ms
memory: 4268kb

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
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
90 2
89 2
...

result:

ok good solution!

Test #58:

score: 6
Accepted
time: 23ms
memory: 4204kb

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: 6
Accepted
time: 24ms
memory: 4488kb

input:

298
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

output:

149
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
101 2
10...

result:

ok good solution!

Test #60:

score: 6
Accepted
time: 25ms
memory: 4496kb

input:

298
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #61:

score: 6
Accepted
time: 21ms
memory: 4820kb

input:

297
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

148
74 3
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
16 2
1...

result:

ok good solution!

Test #62:

score: 6
Accepted
time: 30ms
memory: 4512kb

input:

300
AAAABBBBAAAABBBBBBAABBAABBBBAAAAABBBBBAAAABBBBAAAABBBBBBAABBBAAAABBBBAAAABBBBBBAAAAABBAAABBAAABBBBBAAAABBBBAAABBBBAAAAAABBBBAABBAAAABBBBAAABBBBBAAABBBBBAAAABBAAABBBAABBBAAAABBBAAAAAABBBBBBAAABBAAAAAABBBBBAAAAAABBBBAAAAABBBBAAAABBBBBBAAABBBBAAAAAAABBAAAAAAABBBBBAAAABBBBAAAAABBBAAAAABBBAAAABBBBAAA...

output:

143
35 3
34 2
34 3
36 2
35 2
34 2
33 2
32 2
31 2
31 2
31 2
31 2
30 2
29 2
29 2
31 2
30 2
29 2
29 2
31 2
30 2
29 2
29 2
29 2
31 3
30 2
29 2
30 3
29 2
30 3
29 2
28 2
27 2
26 2
25 2
25 2
24 2
23 2
23 2
22 2
21 2
21 2
23 2
22 2
21 2
21 2
21 2
23 2
22 2
21 2
22 2
21 2
21 2
23 2
22 2
21 2
20 2
19 2
19 2
1...

result:

ok good solution!

Test #63:

score: 6
Accepted
time: 25ms
memory: 4736kb

input:

299
BBBBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABAAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABA...

output:

148
6 3
5 2
4 2
3 2
2 2
92 2
91 2
90 2
89 2
88 2
131 3
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 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: 6
Accepted
time: 25ms
memory: 4364kb

input:

299
BABABABABABABABBBBBBBBBBABABABABABABABABABABABABABBBBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAAAAAABABABAAAAAAAAAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
19 3
18 2
17 2
16 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
23 2
22 2
21 2
20 2
19 2
18 2
88 2
87 2
86 2
85 2
84 2
83 2
...

result:

ok good solution!

Test #65:

score: 6
Accepted
time: 28ms
memory: 4444kb

input:

298
ABABABABABABABABABAAAAABABABABABABABABABAAAABABABABABABABABABABABABABABABABBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABAAAAAABABABABABABABBBBBBABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABBBBBBABAAAAAABABABABABABABABBBBBBBABABABBBBBBABABABABABABABABABABABABABABABABABABABABABA

output:

147
22 2
40 3
72 3
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
24 2
23 2
22 2
21 2
20 2
3...

result:

ok good solution!

Test #66:

score: 6
Accepted
time: 22ms
memory: 4476kb

input:

298
BABABABABABABABAAAAABABABABABABABABABABABABABAAAAAABABABABABABABABABABABABABABABABABABAAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABAAAAAAAAAABBBBABABABAAAAAAAABABABABABABABAAAABABABABABABBBBBABABABABABABABABBBBABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

146
18 2
17 2
44 2
43 2
42 2
41 2
40 2
39 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
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: 6
Accepted
time: 29ms
memory: 4456kb

input:

297
BABABABABABABABABABABABAAAAAAABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABAABBBBBBABAABABABABABABAAAAABABABABABBBBBBBABABABABABABABAAAABABABABAAAABABABBABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABBBBBABABABAABBBBABABABABABABABAB

output:

144
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
29 3
43 3
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
41 2
41 3
41 2
40 2
39 2
38 2
37 3
36 2
34 3
33 2
32 2
31 2
30 2
29 2
28 2
32 3
31 2
30 2
29 2
28 2
27 2
33 3
32 2
31 2
3...

result:

ok good solution!

Test #68:

score: 6
Accepted
time: 26ms
memory: 4764kb

input:

297
BABABABABABABABABABABABABABABABABABABABAABABABABABBBBABABABAAAAAABABABABABABABBBBBABABABABABAAAABABABABABABABABABABABABABBABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABAAAAABABAAAABABAAAAAAABABABABABABAAAAAAAABABABABABAAABABABABABABABABABABABABABABABABBBABABABABABABABBA

output:

145
51 3
59 3
58 2
72 2
71 2
82 3
106 2
105 2
104 2
103 2
107 2
106 2
105 2
104 2
102 3
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 2
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
...

result:

ok good solution!

Test #69:

score: 6
Accepted
time: 18ms
memory: 4180kb

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: 6
Accepted
time: 23ms
memory: 4240kb

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: 6
Accepted
time: 18ms
memory: 4156kb

input:

300
AABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
1 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
101 ...

result:

ok good solution!

Test #72:

score: 6
Accepted
time: 22ms
memory: 4240kb

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: 6
Accepted
time: 22ms
memory: 4164kb

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: 6
Accepted
time: 22ms
memory: 4128kb

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: 6
Accepted
time: 22ms
memory: 4168kb

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: 6
Accepted
time: 22ms
memory: 4220kb

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: 6
Accepted
time: 22ms
memory: 4176kb

input:

299
BAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
3 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: 6
Accepted
time: 22ms
memory: 4160kb

input:

299
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
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
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: 6
Accepted
time: 21ms
memory: 4176kb

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: 6
Accepted
time: 18ms
memory: 4260kb

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: 6
Accepted
time: 21ms
memory: 4168kb

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: 6
Accepted
time: 23ms
memory: 4320kb

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: 6
Accepted
time: 23ms
memory: 4236kb

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: 6
Accepted
time: 26ms
memory: 4492kb

input:

300
ABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABAABBAABBAABBAABBAABBAAABBAABBAAABBAABBAAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBBAABBAABBAABBAABB...

output:

106
2 2
98 2
97 2
96 3
95 3
94 3
93 3
92 3
91 3
90 3
89 3
88 3
87 3
87 2
86 2
85 3
84 3
83 3
83 2
82 2
81 3
80 3
79 3
79 2
78 2
77 3
76 3
75 3
74 3
73 3
72 3
71 3
70 3
69 3
68 3
68 2
67 2
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...

result:

ok good solution!

Test #85:

score: 6
Accepted
time: 25ms
memory: 4708kb

input:

299
BBABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

105
1 2
2 2
1 2
31 2
38 2
55 2
148 2
171 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: 6
Accepted
time: 27ms
memory: 4536kb

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
12 2
11 2
10 3
9...

result:

ok good solution!

Test #87:

score: 6
Accepted
time: 26ms
memory: 4348kb

input:

299
BAABBBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAAABBAABBABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABAB...

output:

132
4 3
6 2
4 3
5 2
4 2
5 2
4 2
5 2
4 2
5 2
4 2
3 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 3
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 2
3 2
4 3
3 2
4 2
3 2
4 2
3 2
4 3
3 2
6 2
4 3
3 2
4 2
3 2
62 2
60 3
58 3
56 3
54 3
52 3
50...

result:

ok good solution!

Test #88:

score: 6
Accepted
time: 25ms
memory: 4396kb

input:

300
AAABBAABBAABBAABBAABBAABBAABBAABBBAAABBAABBAABBAABBAAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

105
33 2
33 2
49 2
68 2
85 2
188 2
187 2
185 3
183 3
181 3
179 3
177 3
175 3
173 3
171 3
169 3
167 3
165 3
163 3
161 3
159 3
157 3
155 3
153 3
151 3
149 3
147 3
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
103 3
101 3
9...

result:

ok good solution!

Test #89:

score: 6
Accepted
time: 27ms
memory: 4824kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABAABBAABBAABBAABBBAABBAABBAABBAAABBAABBAABBAAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABB...

output:

106
96 2
95 2
94 3
93 3
92 3
91 3
90 3
89 3
88 3
88 2
87 2
86 3
85 3
84 3
83 3
82 3
81 3
81 2
80 2
79 3
78 3
77 3
76 3
75 3
75 2
74 2
73 3
72 3
72 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
43 2
4...

result:

ok good solution!

Test #90:

score: 6
Accepted
time: 26ms
memory: 4560kb

input:

299
BBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBBAABAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABB...

output:

123
32 2
53 2
79 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
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 ...

result:

ok good solution!

Test #91:

score: 6
Accepted
time: 28ms
memory: 4508kb

input:

300
ABABABABABABABABABABABABABABAABABABABABABABABABABABBAABBBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABBAABBAABBAABBAABBAAABBAAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABAB...

output:

123
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
7 2
6 2
5 3
4 3
3 3
2 3
4 3
2 3
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 2
2 2
3 3
2 2
3 2
2 2
3 2
2 2
1 2
1 2
...

result:

ok good solution!

Test #92:

score: 6
Accepted
time: 22ms
memory: 4188kb

input:

298
ABABABABABABABABABABABABABABABABAABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB

output:

148
33 2
49 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
99 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: 6
Accepted
time: 19ms
memory: 4480kb

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
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
97 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: 6
Accepted
time: 24ms
memory: 4632kb

input:

298
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB

output:

147
60 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: 6
Accepted
time: 24ms
memory: 4304kb

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
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...

result:

ok good solution!

Test #96:

score: 6
Accepted
time: 20ms
memory: 4432kb

input:

299
AABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #97:

score: 6
Accepted
time: 25ms
memory: 4636kb

input:

300
AABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAA...

output:

-1

result:

ok no solution

Test #98:

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

input:

299
BBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #99:

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

input:

300
BBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #100:

score: 6
Accepted
time: 26ms
memory: 4436kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAA...

output:

-1

result:

ok no solution

Test #101:

score: 6
Accepted
time: 26ms
memory: 4328kb

input:

300
BBAABBBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAA...

output:

-1

result:

ok no solution

Subtask #3:

score: 0
Runtime Error

Test #102:

score: 0
Runtime Error

input:

5998
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #153:

score: 0
Runtime Error

input:

999997
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:


result: