Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
0
Indexable
Never
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int a, b, flag = 1;
	int mas[100][100];
	string mas1[100];
	cin >> a >> b;
	for (int i = 0; i < a;  i++) {
		cin >> mas1[i];
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++){
			cin >> mas[i][j];
		}
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++){
			char n = mas1[i][j];
			if (mas[i][j] == 0){
				if (mas1[i][j] == '.') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 1) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'B') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 2) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'G') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 3) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'G' || mas1[i][j] == 'B') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 4) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'R') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 5) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'R' || mas1[i][j] == 'B') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 6) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'G' || mas1[i][j] == 'R') {
					continue;
				}
				else flag = 0;
			}
			if (mas[i][j] == 7) {
				if (mas1[i][j] == '.' || mas1[i][j] == 'G' || mas1[i][j] == 'B' || mas1[i][j] == 'R') {
					continue;
				}
				else flag = 0;
			}
		}
	}
	if (flag) cout << "YES";
	else cout << "NO";
}