//类似贪心,能直走就直走,不能直走优先左上斜吃
#include <bits/stdc++.h>
using namespace std;
int main()
{
int s,n,ans;
string a,b;
cin>>s;
while(s--)
{
ans=0;
cin>>n>>a>>b;
for(int i=0;i<n;i++)
{
if(b[i]=='1')//找己方棋子
{
if(a[i]=='0') ans++;//前面没敌方棋子:直接移上去
else if(i!=0&&a[i-1]=='1')//前方有敌方棋子1:不是一号位且敌方左上没棋子直接左上斜吃
{
ans++;
a[i-1]='0';
}
else if(i!=n-1&&a[i+1]=='1')//前方有敌方棋子2:不是末号位且敌方右上没棋子直接右上斜吃
{
ans++;
a[i+1]='0';
}
}
}
cout<<ans<<endl;
}
return 0;
}
A - Gregor and the Pawn Game
最新推荐文章于 2024-07-10 22:49:54 发布