QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212634#2968. Team Change275307894aAC ✓15ms6692kbC++142.5kb2023-10-13 18:45:312023-10-13 18:45:31

Judging History

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

  • [2023-10-13 18:45:31]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:6692kb
  • [2023-10-13 18:45:31]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e3+5,M=N*100+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int S,T,x,y,n,m;vector<int> G[N];
struct yyy{int to,w,z;};struct ljb{int head=1,h[N];yyy f[M];void add(int x,int y,int z){f[++head]=(yyy){y,z,h[x]};h[x]=head;}}s;
void con(int x,int y,int z){s.add(x,y,z);s.add(y,x,0);}
int vis[N];
namespace Dicnic{
	int d[N],Ns[N];
	int bfs(){
		queue<int> q;Me(d,0x3f);Mc(Ns,s.h);d[S]=0;q.push(S);
		while(!q.empty()){
			int x=q.front();q.pop();yyy tmp;
			for(int i=s.h[x];i;i=tmp.z){
				tmp=s.f[i];if(tmp.w&&d[tmp.to]>d[x]+1) q.push(tmp.to),d[tmp.to]=d[x]+1;
			}
		}
		return d[T]<INF;
	}
	int dfs(int x,int Sum){
		if(x==T) return Sum;yyy tmp;int k,pus=0;
		for(int &i=Ns[x];i;i=tmp.z){
			tmp=s.f[i];if(!tmp.w||d[tmp.to]!=d[x]+1) continue;k=dfs(tmp.to,min(tmp.w,Sum));
			if(!k) d[tmp.to]=INF;s.f[i].w-=k;s.f[i^1].w+=k;pus+=k;Sum-=k;if(!Sum) break;
		}
		return pus;
	}
	int calc(){int ans=0;while(bfs()) ans+=dfs(S,INF);return ans;}
	void find(int x){cerr<<"find "<<x<<'\n';
		if(vis[x]) return;vis[x]=1;yyy tmp;
		for(int i=s.h[x];i;i=tmp.z) tmp=s.f[i],tmp.w&&(find(tmp.to),0);
	}
}
char c[N],t[N];int col[N];
void dfs(int x,int w){if(col[x]||vis[x]^vis[x+n]) return;col[x]=w;for(int i:G[x]) dfs(i,-w);}
char ans[N];
void Solve(){
	int i,j;scanf("%d%d%s%s",&n,&m,c+1,t+1);S=0;T=2*n+1;
	while(m--) scanf("%d%d",&x,&y),G[x].emplace_back(y),G[y].emplace_back(x),con(x+n,y,INF),con(y+n,x,INF);
	for(i=1;i<=n;i++) if(t[i]^'?'&&!col[i]) dfs(i,t[i]^'B'?1:-1);
	for(i=1;i<=n;i++) con(i,i+n,1);
	for(i=1;i<=n;i++) if(t[i]^'?'){
		if(col[i]*(t[i]^'B'?1:-1)>0) con(S,i,INF),cerr<<"S "<<i<<'\n';else con(i+n,T,INF),cerr<<"T "<<i<<'\n';
	}
	cerr<<Dicnic::calc()<<'\n';
	Dicnic::find(S);
	Me(col,0);for(i=1;i<=n;i++) if(vis[i]==vis[i+n]&&t[i]^'?') dfs(i,t[i]^'B'?1:-1);
	for(i=1;i<=n;i++) if(vis[i]==vis[i+n]&&!col[i]) dfs(i,1);
	for(i=1;i<=n;i++) if(vis[i]^vis[i+n]) ans[i]='X';else ans[i]=(~col[i]?'A':'B');
	printf("%s\n",ans+1);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息

Test #1:

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

input:

5 4
AAABB
??AAA
1 4
2 4
3 4
3 5

output:

BBXAA

result:

ok good plan

Test #2:

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

input:

2 1
AB
AA
1 2

output:

XA

result:

ok good plan

Test #3:

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

input:

8 8
ABBABAAA
?B?ABBAB
1 2
4 3
6 5
4 5
1 5
2 8
3 7
2 4

output:

AXBAXBAB

result:

ok good plan

Test #4:

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

input:

200 10000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

result:

ok good plan

Test #5:

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

input:

200 10000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

result:

ok good plan

Test #6:

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

input:

200 10000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

XAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXABXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBXBX

result:

ok good plan

Test #7:

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

input:

200 10000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
AAABAABBBBBBABBBABABBABBAABAABBABBABAAABBAAAAABBAAAABBAABAAAAABABAABABBABABBABBBABABAABAB...

output:

XXXBXXBBBBBBXBBBXBXBBXBBXXBXXBBXBBXBXXXBBXXXXXBBXXXXBBXXBXXXXXBXBXXBXBBXBXBBXBBBXBXBXXBXBXBBBXXBXXXXAXXAAAAAXXXAXAXXAXAAXXAAXXAAAAAAXXXXAAXXAXAXAXAXXAXXAAAXXAAAAAXAXAAAXXAXAAAXXXAAXAXAXXXXAXAXXAXAAAAX

result:

ok good plan

Test #8:

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

input:

200 10000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
A?B?ABBA??A?B?AB?A?B?AA?B??BAAAB??BABBA???AABABBBBAAB?B?AABBBB?BBABAB?AB?AAABAB?AB??B?A?A...

output:

AAXAAXXAAAAAXAAXAAAXAAAAXAAXAAAXAAXAXXAAAAAAXAXXXXAAXAXAAAXXXXAXXAXAXAAXAAAAXAXAAXAAXAAAAXAXAXAAAAAAXBBXBBBBXBXBBXBXBXBXXBBBXXBBBXBBBBBBBBBBXXXBBBBBBXBBBBBBXBXXBXBBBBBBXBBBBXBBBBBBXXBBBBBBBXBXBXBXXXXB

result:

ok good plan

Test #9:

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

input:

1 0
A
A

output:

A

result:

ok good plan

Test #10:

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

input:

2 1
BA
BB
1 2

output:

XB

result:

ok good plan

Test #11:

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

input:

2 0
AA
BA

output:

BA

result:

ok good plan

Test #12:

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

input:

2 0
AB
B?

output:

BA

result:

ok good plan

Test #13:

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

input:

2 1
AB
B?
1 2

output:

BA

result:

ok good plan

Test #14:

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

input:

1 0
A
B

output:

B

result:

ok good plan

Test #15:

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

input:

1 0
A
?

output:

A

result:

ok good plan

Test #16:

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

input:

1 0
B
A

output:

A

result:

ok good plan

Test #17:

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

input:

1 0
B
B

output:

B

result:

ok good plan

Test #18:

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

input:

1 0
B
?

output:

A

result:

ok good plan

Test #19:

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

input:

2 0
AB
BA

output:

BA

result:

ok good plan

Test #20:

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

input:

2 1
AB
AB
1 2

output:

AB

result:

ok good plan

Test #21:

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

input:

2 1
AB
BA
1 2

output:

BA

result:

ok good plan

Test #22:

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

input:

1000 1000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

XAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXAXA...

result:

ok good plan

Test #23:

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

input:

1000 1000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

BXBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

result:

ok good plan

Test #24:

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

input:

1000 1000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...

result:

ok good plan

Test #25:

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

input:

1000 1000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

XBABXBXBXXABAXBABXABXABXBABXBAXABAXBABAXAXABAXXBABXABAXBABXABXAXABXXAXAXABXXABXBXBABABXAXABXABABXXAXAXAXAXABABAXAXAXBAXABABAXABXBXABAXBABXBAXAXAXBABAXXBXBXBAXBABABXABXBXABXBAXABAXABXBAXBAXBABAXBAXXBXBABAXAXBXBXAXAXAXABXXABXXABXABABXABAXAXBXBAXBXBAXXBAXABXBXABXABAXBXBABABXABAXBXBXBXABXBXABAXBABXXABAX...

result:

ok good plan

Test #26:

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

input:

1000 1000
ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...

output:

ABABABXABAXBABABXBAXBXBABAXABABABABXBABABAXABXABAXABABABABABXBXBABAXBABABXXABAXAXABABXBABXABXABAXBABXBABXABABABABABXABABABAXABABABXBXBABABABABABXBABABAXABXBABAXBABXBAXABXBAXABABABABABXXABXBABABXBAXAXBABABABAXABABABABAXABABAXBABXBABABAXABAXABABAXABAXXBABXBABAXAXABAXABABABXBABAXABAXAXABAXABAXABXXABABA...

result:

ok good plan

Test #27:

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

input:

1000 0
BABAAABBBAABBBAABAAAAAABAAABBBBBBAAAAAAAAAABBBBABAABBBABABBBABBBBBABBABBAABAAAAABBAABABBBABBBBBABABAABBBBBAABBBBAAAABBBBABBABBABBBBABABABBBBABAABAAABBBABAABBAABABABAAAABBBABBBBBAAABABBAAAAABAABBBABBAABBBBABAAAABAAAAAAAAABBABBBAAABBBABBABABBAAAAABAABBBBBABBBABABABBABBBBABAAABBAABAABBAABBABAABB...

output:

ABBBBAABBAAABBAAAAAAAAAABAABAABABAAABAABABABBAAAAABAAABBBBAABBBAABAAAAAABAAAABBAAAAAAABAABBBBBBBBAABAAABABAABBAAAAABBAAAABBAAAABAAAAAABBAAAAAAAABBABABAABAABABAAABAAAABBAAABABAABBAAAAAAABABABAABABAAAAAAAABABAAAAABBBBABBAAAAAAAAAAAAABBBBBAAAAABBBAAAAAAAABAAABAAAABAAABBAAABBAABABABBBBBBBABAABBAABABBAAB...

result:

ok good plan

Test #28:

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

input:

1000 10000
ABAABBAAAABAABBBABABBABBBABBBBBBAABAAABBBBBABBAABBAAAAABBAABBBBABBBBAAABAAAABABBBBABBABAAABBBABBABAABBAABABBABAAAABABBABAABBBBBAAAAAAABAABABBABAAAAABBBBBABAABBAABBBABBBABBBBAABABABAAABAAABBABBABBBAAABBBBAABBAABABBBABBAAAABBAAABBAAAABBABBBABBBAABBBBAAAABAABABAAAAAABBBBBBBABBABBBBAAAABAAAAB...

output:

XXAAXBAAAABAXBXXAXABBAXXBXBXBBBBAXBAAABBXBBXXBAAXBXAXAXXXAABBBXXBBBXAXABAAAAXXBBBBAXXXBAAABXBABBXBAABBXXBXBBXXAXAABAXXABXABBBBBXAAAAXABXABXXBXXAXAXABBBBXABAABXAABBBAXBBXXBBBXXBABXBAAABAXABBABBAXBXAAXBBXBAAXBXABABBXXXXAXAABBXAABXAXAXBBXBXBAXXBAAXBBXXAAXXAAXAXAAXAAABBBBXBXXXXABBBXAAXABXAAAXBBBBBAABBBB...

result:

ok good plan

Test #29:

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

input:

1000 10000
BAAABBBBAAABBBBAABABBABBBBBAAAABABABBBABAAABBABABBBABAABABBAABABAAABBAABBABBBBBBBBBBBBBABAAAABABBBBAAAABBABABABBAABAAABABBBAAAABBBAAABBBBBAAAAAABABBBBBBAABABBABAAABBABAAAAABBBBBBBABBAAAAABABBBAAABAABBBAABABBBBBBBABAABABABAAAAABBBBAABAAAABBBBAAAAABABBBABABBABBAAABBBABABABBABAAAAABBABAAABBB...

output:

BAAXBBXXAXABBXXAABXXXABBBBBAXAXXABABXXAXXXABXABAXBXAXAABABBAABAXXAAXBXABBABBXBBBBBBXBBXABXXXAXABBBBAAAXXBXBABXBBAAXAAABABBBXAAAXBBAAABBBXXXXAXAABABBBBBBAABXBBXXAAXXBABXXAXABXBXXXBABXAAAXABAXXBAAXBAXXXBAAXABBBXBBBABAXBXBABXAAAABBBBAABAXAABXBXAAXAABXBBBABAXBABXAXAXBXABABXBBXBAAAAXXXABXAAXXBBAAXXABAAAX...

result:

ok good plan

Test #30:

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

input:

1000 10000
AAABABBBAABABBBBBBABBABAABBBAABBAAAAAAAABABBAABBAAABBAAAAAABBBAABAABBABAABAAABBAABABBBBBBBBAABABBABBBBABABBBAAAAABAABAAABBABAAABAAABBBAAABABBBBBBAABAABABABAABABABABAABAAABABBABBAABBAABBAAABABAABBAAAAABBBAAABBABBBABAABAAAAABABBBABBBBABAAABABBBBAABAABBBAAABAAABAABAAAABBBAAAABAABAAABBAABBBBA...

output:

XXBAXXAXBXXBAAXAXXXAABAXBAXABBXXBXBBBBBBABAABBAXBBXAAXBBBBXAXABBAXBXABABBAXXBAABXXBXAXXAAAABXABAABAAXXBXXAAABBBBBABBAXXBAXBABBBXBBBAAAXBBABAAAXAXBXABBABXBXXBABXBXBAXBXXBBXBAXBXABBAABBAABXBAXABXXXBBXBBAXAXBBXABXAABABBABBBXXXXAXAXAAAABABXXABXXAXBBABBAXXBBBAXXBABBAXBBXAAABXBXXBBAXXBXXBBAXXXBAXBAAXBBBAA...

result:

ok good plan

Test #31:

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

input:

1000 10000
BBAAAABAAAABAABAABABAAAAABABBABBABABBAAABBABBBBAAAAABAAAABBABBBBAAABBBBBBBAAABAAABABAABBBABABABAABAAABBBBABBBBAAAABBAAABABABABBBABBABBBAAABABABABABAABBABBBABBAAAAAABBAAABABBBABAAAABBBBBBBBABAABBBBAABBBBBBAABBABBAABABBABAAABABBABBBBABBBBABBABAABBABBBBBBBABABABAAAABBBBBBAABBBBBABBABAABABBBB...

output:

AXXXBXABXBBAXBABBAXABXBXXAXXXBAAXABAABXXXAXAAXABBBXXXBBBBXABAXAAXBXXAXXAXABBBAXBXABXXBXAXBABABXBBABXBAAAAXAXAXBBXBAABBXXXAXXBAAABAABAXXBBBAXXXXXABXBBAABAAABAXXBXXBBAABBXABAAXXABBBBAXAXXAXXXXBBXXAAXBXAAXXABXAABXAXBAXAAXAXXXABXXXAAAAXAXAAXXABABBAXBXAAAAXABABABXXBXBAAXAAXBBAAAAAXAXBABBABXAXAXXAAABABBXB...

result:

ok good plan

Test #32:

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

input:

1000 10000
AABAABBABBBAABAABABBAAAAAABAABABBAABAAAABBAABAABBBABBAABAABAABABBAABBABBAABAABBAABBAAAAAABAABBBBABABBBBABBBAAABBAAABBABBBAABBBBAABAAAAABBBBBABAABAABBABBBBBAAAABBAABAAAABBBABBAAAAABAAAABBAAAAABBAAABBABAABBBBBBABBABBABBAABABAABAAAABBBBAAAABBABBABBABBAAABAAAABBABABABBBBAABABBAAAABBAABABAAABB...

output:

XABAXBBABBXXAXAABXBBAAXXAABAABAXBAAXAAAXBBAAXAABXBAXBXXXXABAABXBXXABBXBXAAXAAXBAXXBAAAAAABAXBBXBXBABXBBXBBXAAABXAXXXBABXBAABBBBXABXAAAXBXBBBABAABXXBBABXBBXAAXABBAABXAAABXBABXAAAAXBAAAXBXAAXXAXBAAABBXBXXBBBBBBXXBAXBABXAAXAXXAXAAXABXBBAAAABBXBBAXBABXXXABAAAABXXBAXABBXXXABXBXXAAABBAXBXXAXABBBXXABXABXXX...

result:

ok good plan

Test #33:

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

input:

1000 999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

result:

ok good plan

Test #34:

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

input:

1000 999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

BBAAAAAABAABBBBAABBBBBBBAAAAABBABAABAABBAAABBBAABAABBBAAAABABBABBAXBBABAAABBABBBBAABAAAABAABBBABBBAABAABABBABABABAAABAABAAAABABBABBAABBABAABBBAAABAABABBABBAABBABABBAAABABBBAAABABBBABBBBABBAAABBAAABAAABABBAABBBBBBAABAAAABAABAAABAAAAABABAABABBABBAAAAAAABBBBBBBAAAAAAABABABAABBBBBAABABBBBBABBBBBBBBAABAB...

result:

ok good plan

Test #35:

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

input:

1000 999
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

AAAABAABAAABBBBBAAAAABAAAAAAAABABAABAABAABAAAABBBAAABAAABBABBAAAABXBAAABABABABABBAAAABBABBBAAABABBBBAAABABAABAABAAAAAAAAAAAABABABBBBAAABAAAABABABBBAABBBAAAABABABAABABAAABABBAAAAAAAABAAAAAAAAAAAAAAAAABBAABABAAAAAABABAAAAAAAAAAABBABAAAABBAAAAAABBABBABAAAABAAAAAAAABABAABBAAAABABAAAABAABBAAAAAAABBABBABA...

result:

ok good plan