QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637321#4273. Good Gamechenxinyang20060 16ms155020kbC++203.2kb2024-10-13 12:08:412024-10-13 12:08:41

Judging History

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

  • [2024-10-13 12:08:41]
  • 评测
  • 测评结果:0
  • 用时:16ms
  • 内存:155020kb
  • [2024-10-13 12:08:41]
  • 提交

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,m,k;
char s[1000005];
int a[1000005],b[1000005],c[1000005];

vector <pii> answer;
int top;
int stk[1000005];
void psh(int v){
//	printf("psh %d\n",v);
	stk[++top] = v;
}
int pick(){
	assert(top);
	return stk[top--];
}
void clr(int l,int r){
//	printf("clr [%d,%d]\n",l,r);
	assert(r > l);
	if(l % 2 == r % 2){
		answer.eb(l,3);
		r -= 3;
	}
	while(l <= r){
		answer.eb(l,2);
		r -= 2;
	}
}
int dp[6005][6005];
int main(){
//	freopen("test.in","r",stdin);
	scanf("%d",&n);
	scanf("%s",s + 1);
	for(int l = 1,r;l <= n;l = r + 1){
		r = l;
		while(r < n && s[r] == s[r + 1]) r++;
		a[++m] = r - l + 1;
	}

	k = 0;
	rep(i,1,m){
		if(a[i] == 1) b[k]++;
		else c[++k] = a[i];
	}
	if(!k){
		printf("-1\n");
		return 0;
	}
	memset(dp,0,sizeof(dp));
	dp[0][b[0]] = 1;
	rep(i,1,k - 1){
		rep(x,0,m){
			if(!dp[i - 1][x]) continue;
			if(b[i] - x >= 0) dp[i][b[i] - x] = 1;
			rep(y,max(b[i] + 1 - x,x - (b[i] + 1)),b[i] + 1 + x) if((x + y) % 2 != b[i] % 2) dp[i][y] = 1;
		}
	}
/*	rep(i,1,m) printf("%d ",a[i]);
	printf("\n");
	rep(i,0,k) printf("%d ",b[i]);
	printf("\n");
	rep(i,1,k) printf("%d ",c[i]);
	printf("\n");*/
	if(!dp[k - 1][b[k]]){
		printf("-1\n");
		return 0;
	}
	rep(i,1,b[k]) psh(1);
	int x = b[k],y,aa,bb,sum = n - b[k];
	per(i,k - 1,0){
		y = x;x = aa = bb = -1;
		if(i){
			rep(xx,0,m){
				if(!dp[i - 1][xx]) continue;
				if(b[i] - xx == y){
					x = xx;
					aa = x;
					bb = y;
				}
				rep(yy,max(b[i] + 1 - xx,xx - (b[i] + 1)),b[i] + 1 + xx){
					if((xx + yy) % 2 != b[i] % 2 && yy == y){
//						printf("transfer %d->%d ok\n",xx,yy);
						x = xx;
						aa = (b[i] + 1 + x - y) / 2;
						bb = (b[i] + 1 - x + y) / 2;
					}
				}
			}			
		}else{
			x = 0;
			bb = b[i];
		}
//		printf("i=%d y=%d chose x=%d bb=%d sum=%d\n",i,y,x,bb,sum);
		assert(x != -1);
		assert(bb <= b[i] + 1);
		sum -= c[i + 1];
		psh(c[i + 1]);
		rep(kk,1,bb){
			clr(sum + 1,sum + pick());
			if(kk != b[i] + 1){
				stk[top]++;
				sum--;
			}else{
				sum -= c[i];
				c[i] += pick();
				sum += c[i];
			}
		}
		rep(kk,1,b[i] - bb){
			psh(1);
			sum--;
		}
	}
	rep(i,1,top) clr(1,stk[i]);
	printf("%d\n",SZ(answer));
	for(pii I:answer) printf("%d %d\n",I.first,I.second);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 3ms
memory: 151384kb

input:

9
ABAABBBAA

output:

4
3 2
2 2
2 2
1 3

result:

ok good solution!

Test #2:

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

input:

13
ABABBABABBABA

output:

6
9 2
8 2
4 2
3 2
2 3
1 2

result:

ok good solution!

Test #3:

score: 3
Accepted
time: 8ms
memory: 154608kb

input:

15
AABABAABABAABAB

output:

7
11 2
10 2
6 2
5 2
4 3
1 2
1 2

result:

ok good solution!

Test #4:

score: 3
Accepted
time: 7ms
memory: 152832kb

input:

15
ABAABBBABAABBAB

output:

7
12 2
10 3
3 2
2 2
2 2
1 2
1 2

result:

ok good solution!

Test #5:

score: 3
Accepted
time: 1ms
memory: 9976kb

input:

1
B

output:

-1

result:

ok no solution

Test #6:

score: 3
Accepted
time: 4ms
memory: 152728kb

input:

2
BB

output:

1
1 2

result:

ok good solution!

Test #7:

score: 0
Wrong Answer
time: 16ms
memory: 152532kb

input:

7
AAAABBB

output:

3
1 3
1 2
1 2

result:

wrong answer invalid operation on step #2: AB

Subtask #2:

score: 0
Wrong Answer

Test #51:

score: 6
Accepted
time: 4ms
memory: 151388kb

input:

299
ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

-1

result:

ok no solution

Test #52:

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

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...

output:

-1

result:

ok no solution

Test #53:

score: 6
Accepted
time: 4ms
memory: 152984kb

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

149
199 2
199 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
160 2
159 2
158 2
157 2
156 2
155 2
154 2
153 2
15...

result:

ok good solution!

Test #54:

score: 6
Accepted
time: 12ms
memory: 151508kb

input:

299
BBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

148
200 3
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
160 2
159 2
158 2
157 2
156 2
155 2
154 2
153 2
10...

result:

ok good solution!

Test #55:

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

input:

297
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

output:

148
224 2
222 3
221 2
220 2
219 2
218 2
217 2
216 2
215 2
214 2
213 2
212 2
211 2
210 2
209 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
17...

result:

ok good solution!

Test #56:

score: 6
Accepted
time: 4ms
memory: 153196kb

input:

300
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
209 3
208 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
16...

result:

ok good solution!

Test #57:

score: 6
Accepted
time: 8ms
memory: 154364kb

input:

299
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBAABBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

149
209 2
206 2
206 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
199 2
198 2
197 2
196 2
195 2
194 2
193 2
192 2
191 2
190 2
189 2
188 2
187 2
186 2
185 2
184 2
183 2
182 2
181 2
180 2
179 2
178 2
177 2
176 2
175 2
174 2
173 2
172 2
171 2
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
16...

result:

ok good solution!

Test #58:

score: 6
Accepted
time: 4ms
memory: 151500kb

input:

300
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAAAABBAAAABABABABABABABABABABABABABABABABABABABABABAB...

output:

150
248 2
244 2
244 2
244 2
244 2
243 2
242 2
241 2
240 2
239 2
238 2
237 2
236 2
235 2
234 2
233 2
232 2
231 2
230 2
229 2
228 2
227 2
226 2
225 2
224 2
223 2
222 2
221 2
220 2
219 2
218 2
217 2
216 2
215 2
214 2
213 2
212 2
211 2
210 2
209 2
208 2
207 2
206 2
205 2
204 2
203 2
202 2
201 2
200 2
19...

result:

ok good solution!

Test #59:

score: 6
Accepted
time: 4ms
memory: 149672kb

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

input:

298
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

-1

result:

ok no solution

Test #61:

score: 0
Wrong Answer
time: 4ms
memory: 149564kb

input:

297
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

output:

148
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:

wrong answer invalid operation on step #75: BAA

Subtask #3:

score: 0
Wrong Answer

Test #102:

score: 7
Accepted
time: 12ms
memory: 152156kb

input:

5998
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2998
3995 3
3995 2
3995 2
3995 2
3994 2
3993 2
3992 2
3991 2
3990 2
3989 2
3988 2
3987 2
3986 2
3985 2
3984 2
3983 2
3982 2
3981 2
3980 2
3979 2
3978 2
3977 2
3976 2
3975 2
3974 2
3973 2
3972 2
3971 2
3970 2
3969 2
3968 2
3967 2
3966 2
3965 2
3964 2
3963 2
3962 2
3961 2
3960 2
3959 2
3958 2
3957 2
3...

result:

ok good solution!

Test #103:

score: 7
Accepted
time: 3ms
memory: 155020kb

input:

5999
BBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

2998
4000 3
4000 2
3999 2
3998 2
3997 2
3996 2
3995 2
3994 2
3993 2
3992 2
3991 2
3990 2
3989 2
3988 2
3987 2
3986 2
3985 2
3984 2
3983 2
3982 2
3981 2
3980 2
3979 2
3978 2
3977 2
3976 2
3975 2
3974 2
3973 2
3972 2
3971 2
3970 2
3969 2
3968 2
3967 2
3966 2
3965 2
3964 2
3963 2
3962 2
3961 2
3960 2
3...

result:

ok good solution!

Test #104:

score: 7
Accepted
time: 7ms
memory: 151432kb

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2998
4500 2
4497 2
4497 2
4496 2
4495 2
4494 2
4493 2
4492 2
4491 2
4490 2
4489 2
4488 2
4487 2
4486 2
4485 2
4484 2
4483 2
4482 2
4481 2
4480 2
4479 2
4478 2
4477 2
4476 2
4475 2
4474 2
4473 2
4472 2
4471 2
4470 2
4469 2
4468 2
4467 2
4466 2
4465 2
4464 2
4463 2
4462 2
4461 2
4460 2
4459 2
4458 2
4...

result:

ok good solution!

Test #105:

score: 7
Accepted
time: 7ms
memory: 153156kb

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2999
4198 2
4197 2
4197 2
4196 2
4195 2
4194 2
4193 2
4192 2
4191 2
4190 2
4189 2
4188 2
4187 2
4186 2
4185 2
4184 2
4183 2
4182 2
4181 2
4180 2
4179 2
4178 2
4177 2
4176 2
4175 2
4174 2
4173 2
4172 2
4171 2
4170 2
4169 2
4168 2
4167 2
4166 2
4165 2
4164 2
4163 2
4162 2
4161 2
4160 2
4159 2
4158 2
4...

result:

ok good solution!

Test #106:

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

input:

5999
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2999
4197 3
4195 2
4195 2
4195 2
4194 2
4193 2
4192 2
4191 2
4190 2
4189 2
4188 2
4187 2
4186 2
4185 2
4184 2
4183 2
4182 2
4181 2
4180 2
4179 2
4178 2
4177 2
4176 2
4175 2
4174 2
4173 2
4172 2
4171 2
4170 2
4169 2
4168 2
4167 2
4166 2
4165 2
4164 2
4163 2
4162 2
4161 2
4160 2
4159 2
4158 2
4157 2
4...

result:

ok good solution!

Test #107:

score: 7
Accepted
time: 8ms
memory: 151332kb

input:

5998
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:

2998
4996 3
4994 3
4994 2
4993 2
4992 2
4991 2
4990 2
4989 2
4988 2
4987 2
4986 2
4985 2
4984 2
4983 2
4982 2
4981 2
4980 2
4979 2
4978 2
4977 2
4976 2
4975 2
4974 2
4973 2
4972 2
4971 2
4970 2
4969 2
4968 2
4967 2
4966 2
4965 2
4964 2
4963 2
4962 2
4961 2
4960 2
4959 2
4958 2
4957 2
4956 2
4955 2
4...

result:

ok good solution!

Test #108:

score: 7
Accepted
time: 4ms
memory: 152580kb

input:

5997
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

2998
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 #109:

score: 7
Accepted
time: 3ms
memory: 154252kb

input:

6000
ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

-1

result:

ok no solution

Test #110:

score: 0
Wrong Answer
time: 4ms
memory: 149760kb

input:

5999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

2999
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:

wrong answer invalid operation on step #1478: BA

Subtask #4:

score: 0
Time Limit Exceeded

Test #153:

score: 0
Time Limit Exceeded

input:

999997
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

output:


result: