Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <queue>
- #include <cassert>
- #include <vector>
- #include <string>
- using namespace std;
- typedef long long ll;
- char buf[2][3];
- char mp[512][513];
- char txt[5];
- int main()
- {
- int k;
- scanf("%d",&k);
- map<string,int> nice;
- while(k--)
- {
- for(int i=0;i<2;i++)
- scanf("%s", buf[i]);
- txt[0] = buf[0][0];
- txt[1] = buf[0][1];
- txt[2] = buf[1][1];
- txt[3] = buf[1][0];
- txt[4] = 0;
- string cur = txt;
- for(int j=0;j<4;j++)
- {
- cur = min(cur, string(txt));
- rotate(txt, txt+1, txt+4);
- }
- nice[cur]++;
- }
- int n,m;
- scanf("%d%d",&n,&m);
- for(int i=0;i<n;i++)
- scanf("%s", mp[i]);
- for(int i=0;i<n;i+=2)
- for(int j=0;j<m;j+=2)
- {
- txt[0] = mp[i][j];
- txt[1] = mp[i][j+1];
- txt[2] = mp[i+1][j+1];
- txt[3] = mp[i+1][j];
- txt[4] = 0;
- string cur = txt;
- for(int j=0;j<4;j++)
- {
- cur = min(cur, string(txt));
- rotate(txt, txt+1, txt+4);
- }
- if(nice[cur] == 0)
- {
- puts("No");
- return 0;
- }
- nice[cur]--;
- }
- puts("Yes");
- return 0;
- }
Add Comment
Please, Sign In to add comment