- Get link
- X
- Other Apps
B. Colourblindness
Vasya has a grid with
Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.
The input consists of multiple test cases. The first line contains an integer
The first line of each test case contains an integer
The following two lines each contain a string consisting of
For each test case, output "YES" if Vasya considers the grid's two rows to be identical, and "NO" otherwise.
You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
62RGRB4GRBGGBGB5GGGGGBBBBB7BBBBBBBRRRRRRR8RGBRRGBRRGGRRBGR1GG
YES NO YES NO YES YES
In the first test case, Vasya sees the second cell of each row as the same because the second cell of the first row is green and the second cell of the second row is blue, so he can't distinguish these two cells. The rest of the rows are equal in colour. Therefore, Vasya will say that the two rows are coloured the same, even though they aren't.
In the second test case, Vasya can see that the two rows are different.
In the third test case, every cell is green or blue, so Vasya will think they are the same.
Solution with C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
string x,y;
cin>>t;
while(t)
{
t--;
cin>>n>>x>>y;
int bj=0;
for(int i=0; i<n; i++)
{
if(x[i]=='R'&&y[i]!='R') bj=1;
if(x[i]=='G'&&y[i]=='R') bj=1;
if(x[i]=='B'&&y[i]=='R') bj=1;
}
if(bj) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
- Get link
- X
- Other Apps
Comments
Post a Comment