Below code is giving wrong answer ,I dont know in which case it fails:
#include<iostream>
#include<cstdio>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
FAST_IO
int T;
cin>>T;
string top,botm;
while(T--)
{
int flag_b=0,flag_o=0;
cin>>top>>botm;
if(top =="bob" || top =="obb" || top =="bbo")
cout<<"yes"<<"\n";
else if(botm =="bob" || botm =="obb" || botm =="bbo")
cout<<"yes"<<"\n";
else
{
for(int i=0;i<top.length();i++)
{
if(top[i]=='b' && flag_b<2)
{
flag_b++;
}
else if(botm[i]=='b' && flag_b<2)
{
flag_b++;
}
else if(top[i]=='o' && flag_o<1)
{
flag_o++;
}
else if(botm[i]=='o' && flag_o<1)
{
flag_o++;
}
}
if(flag_b==2 && flag_o == 1)
cout<<"yes"<<"\n";
else
cout<<"no"<<"\n";
}
}
return 0;
}