Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <stack>
- #include <iomanip>
- #include <fstream>
- #include <string>
- #include <set>
- #include <deque>
- #include <queue>
- #include <map>
- #include <bitset>
- #include <random>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- #define endl "\n"
- #define sqrt sqrtl
- #define all(a) a.begin(), a.end();
- const ll inf = 1e9 + 13;
- long double eps = 1e-6;
- const ll maxsz = 1e6 + 5;
- ll mod = 1e9 + 7;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- ll n, i, j, x, y, z;
- cin >> n;
- multiset <vector <vector <char> > > a;
- for (i = 0; i < n; i++) {
- vector <vector <char> > sup(2, vector <char>(2));
- for (x = 0; x < 2; x++) {
- for (y = 0; y < 2; y++) {
- cin >> sup[x][y];
- }
- }
- a.insert(sup);
- }
- ll m;
- cin >> n >> m;
- vector <vector <char> > key(n, vector <char>(m));
- for (i = 0; i < n; i++) {
- for (j = 0; j < m; j++) {
- cin >> key[i][j];
- }
- }
- for (i = 0; i < n; i += 2) {
- for (j = 0; j < m; j += 2) {
- vector <vector <char> > sup1(2, vector <char>(2));
- vector <vector <char> > sup2(2, vector <char>(2));
- vector <vector <char> > sup3(2, vector <char>(2));
- vector <vector <char> > sup4(2, vector <char>(2));
- //
- sup1[0][0] = key[i][j];
- sup1[0][1] = key[i][j + 1];
- sup1[1][0] = key[i + 1][j];
- sup1[1][1] = key[i + 1][j + 1];
- //
- sup2[0][0] = sup1[0][1];
- sup2[0][1] = sup1[1][1];
- sup2[1][0] = sup1[0][0];
- sup2[1][1] = sup1[1][0];
- //
- sup3[0][0] = sup2[0][1];
- sup3[0][1] = sup2[1][1];
- sup3[1][0] = sup2[0][0];
- sup3[1][1] = sup2[1][0];
- //
- sup4[0][0] = sup3[0][1];
- sup4[0][1] = sup3[1][1];
- sup4[1][0] = sup3[0][0];
- sup4[1][1] = sup3[1][0];
- //
- auto a1 = a.find(sup1);
- auto a2 = a.find(sup2);
- auto a3 = a.find(sup3);
- auto a4 = a.find(sup4);
- if (a1 == a.end() && a2 == a.end() && a3 == a.end() && a4 == a.end()) {
- cout << "NO" << endl;
- return 0;
- }
- else {
- if (a1 != a.end()) {
- a.erase(a1);
- }
- else {
- if (a2 != a.end()) {
- a.erase(a2);
- }
- else {
- if (a3 != a.end()) {
- a.erase(a3);
- }
- else {
- a.erase(a4);
- }
- }
- }
- }
- }
- }
- cout << "YES" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement