题意就是让你构造 (n+m)*2 长度的字符串 使得有 n 个 子序列为 AB m个 子序列为BA
问你有多种方案
首先我们思考一个问题 就是如果构造 n 个AB 贪心的取前n个为A 我们看这样一个问题 假如你前 n 个A不都拿来当 AB 那么有一个是构造BA 那么你取第n个之后的A也能构造成BA 所以这样贪是对的
也就是 A的个数一定是小于等于 当前 B 的个数 + n
那么 B也同理了 取前 m 个 于是就可以 dp出来了
/*
if you can't see the repay
Why not just work step by step
rubbish is relaxed
to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef pair<int,