因为我们知道三个串里面一定有两个串的0个数都大于或者都小于n个。
所以我们就随便挑两个这样的串,让里面的0或者1成为他们的公共子序列。
就欢乐ac了,这也太水了
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[4][200005];
bool visa[200005],visb[200005];
int n,cnt[4];
int judge(int a,int b)
{
// printf("%d %d %d %d %d\n",a,b,cnt[a],cnt[b],n);
if(cnt[a]>=n&&cnt[b]>=n)return 1;
else if(cnt[a]<=n&&cnt[b]<=n)return 2;
else return 0;
}
void print(int a,int b,int w)
{
// printf("%d %d %d\n",a,b,w);
char c;
if(w==1)c='0';
else c='1';
int pa=1,pb=1;
while(pa<=2*n||pb<=2*n)
{
if(s[a][pa]==c&&s[b][pb]==c&&pa<=2*n&&pb<=2*n)
{
printf("%c",c);
pa++,pb++;
}
else if(s[a][pa]!=c&&pa<=2*n)
{
printf("%c",s[a][pa]);
pa++;
}
else if(s[b][pb]!=c&&pb<=2*n)
{
printf("%c",s[b][pb]);
pb++;
}
else if(s[b][pb]==c&&pa>2*n)
{
printf("%c",c);
pb++;
}
else if(s[a][pa]==c&&pb>2*n)
{
printf("%c",c);
pa++;
}
}
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=3;i++)scanf("%s",s[i]+1);
for(int i=1;i<=3;i++)
{
cnt[i]=0;
for(int j=1;j<=2*n;j++)
{
if(s[i][j]=='0')cnt[i]++;
}
// cout<<cnt[i]<<endl;
}
for(int i=1;i<=3;i++)
for(int j=1;j<=3;j++)
{
if(i==j)continue;
if(judge(i,j))
{
print(i,j,judge(i,j));
goto endd;
}
}
endd:;
}
return 0;
}