What could be the possible error in my code, I have tested almost all edge cases and a couple of the prescribed test cases also. Attached herewith is my code:
#include <bits/stdc++.h>
using namespace std;
#define NEWLINE "\n";
typedef long long ll;
int count(string s, char c)
{
int res = 0;
for (int i=0;i<s.length();i++)
if (s[i] == c)
res++;
return res;
}
int main()
{
ios::sync_with_stdio(false);
ll T;
cin >> T;
string faceUp, faceDown;
while(T--)
{
cin >> faceUp;
cin >> faceDown;
char k = 'b';
char h = 'o';
int faceUB = count(faceUp, k);
int faceUO = count(faceUp, h);
int faceDB = count(faceDown, k);
int faceDO = count(faceDown, h);
if(faceUB + faceDB < 2 || faceUO + faceDO < 1)
{
cout << "no" << NEWLINE;
break;
}
bool flag = true;
if(faceUp == "bob" || faceUp == "obb" || faceUp == "bbo")
{
cout << "yes" << NEWLINE;
continue;
}
else if(faceDown == "bob" || faceDown == "obb" || faceDown == "bbo")
{
cout << "yes" << NEWLINE;
continue;
}
vector<int> up = {-1, -2, -3}, down = {-4, -5, -6};
int counterUp = 0, counterDown = 0;
for(int i = 0; i < 3; i++)
{
if(faceUp[i] != 'b' && faceUp[i] != 'o')
up[counterUp] = i;
counterUp++;
}
for(int z = 0; z < 3; z++)
{
if(faceDown[z] != 'b' && faceDown[z] != 'o')
down[counterDown] = z;
counterDown++;
}
for(int j = 0; j < 3; j++)
{
if(up[j] == down[j])
{
cout << "no" << NEWLINE;
flag = false;
break;
}
}
if(!flag)
continue;
cout << "yes" << NEWLINE;
}
return 0;
}