Problem - B - Codeforces
codeforces.com
Green == Blue
- 제목
Colourblindness
- 조건
time limit per test : 1 second
memory limit per test : 256 megabytes
input : standard input
output : standard output
- 문제
Vasya has a grid with 2 rows and n columns. He colours each cell red, green, or blue.
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 t (1≤t≤100) — the number of test cases. The description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤100) — the number of columns of the grid.
The following two lines each contain a string consisting of n characters, each of which is either R, G, or B, representing a red, green, or blue cell, respectively — the description of the grid.
- 출력
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).
예제 입력1 | 예제 출력1 |
6 2 RG RB 4 GRBG GBGB 5 GGGGG BBBBB 7 BBBBBBB RRRRRRR 8 RGBRRGBR RGGRRBGR 1 G G |
YES NO YES NO YES YES |
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define endl '\n'
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tc, sz;
string str1, str2;
cin >> tc;
while(tc--){
cin >> sz;
cin >> str1 >> str2;
bool check = true;
for(int n = 0 ; n < sz ; n++){
if(str1[n] == str2[n]) continue;
else{ // !=
if(str1[n] == 'R' || str2[n] == 'R'){
check = false;
break;
}
else continue;
}
}
if(check) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}