全wa求助
查看原帖
全wa求助
660711
GoldHole楼主2022/8/8 09:11

我自己测了几组样例都是对的,但是提交了就是全wa。 求hack数据。

#include <bits/stdc++.h>
#define il inline 
#define rep(l,r) for(int i=l;i<=r;i++)
#define inf 2e9
using namespace std;
const int N = 300005;
int n;
char s[1000005];
int t;
il void sol() {
	int c,x;
	cin>>n>>c>>x;
	int a=0,b=0,d=2*n-c;
	cin>>s+1;
	rep(1,2*n){
		if(s[i]=='A') a++;
		else b++;
	}
	if((a+c-x)<0||(a+c-x)%2){
		cout<<-1;
		if(t!=0) puts(""); 
		return;
	}
	int k=(a+c-x)/2,ac=c-k;
	if(a<k||c-k>b||d-a+k<0){
		cout<<-1;
		if(t!=0) puts(""); 
		return;
	}
	int bc=a-k,bd=2*n-c-bc;
	//cout<<a<<" "<<b<<" ";
	//cout<<k<<" "<<ac<<" "<<bd<<" "<<bc<<'\n';
	rep(1,2*n){
		if(s[i]=='A'){
			if(k) cout<<"A",k--;
			else cout<<"B"; 
		}
		else{
			if(ac) cout<<"A",ac--;
			else cout<<"B";
		}
	}
	if(t!=0) puts("");
}
signed main() {
	cin.tie(0);
	cin>>t;
	while(t--)
		sol();
	return 0;
}
2022/8/8 09:11
加载中...