knightL

Yandex B

Oct 9th, 2021 (edited)
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <set>
  4. #include <map>
  5. #include <queue>
  6. #include <cassert>
  7. #include <vector>
  8. #include <string>
  9. using namespace std;
  10.  
  11. typedef long long ll;
  12.  
  13. char buf[2][3];
  14. char mp[512][513];
  15. char txt[5];
  16.  
  17. int main()
  18. {
  19.     int k;
  20.     scanf("%d",&k);
  21.  
  22.     map<string,int> nice;
  23.     while(k--)
  24.     {
  25.         for(int i=0;i<2;i++)
  26.             scanf("%s", buf[i]);
  27.         txt[0] = buf[0][0];
  28.         txt[1] = buf[0][1];
  29.         txt[2] = buf[1][1];
  30.         txt[3] = buf[1][0];
  31.         txt[4] = 0;
  32.  
  33.         string cur = txt;
  34.         for(int j=0;j<4;j++)
  35.         {
  36.             cur = min(cur, string(txt));
  37.             rotate(txt, txt+1, txt+4);
  38.         }
  39.         nice[cur]++;
  40.     }
  41.  
  42.     int n,m;
  43.     scanf("%d%d",&n,&m);
  44.     for(int i=0;i<n;i++)
  45.         scanf("%s", mp[i]);
  46.  
  47.     for(int i=0;i<n;i+=2)
  48.         for(int j=0;j<m;j+=2)
  49.         {
  50.             txt[0] = mp[i][j];
  51.             txt[1] = mp[i][j+1];
  52.             txt[2] = mp[i+1][j+1];
  53.             txt[3] = mp[i+1][j];
  54.             txt[4] = 0;
  55.  
  56.             string cur = txt;
  57.             for(int j=0;j<4;j++)
  58.             {
  59.                 cur = min(cur, string(txt));
  60.                 rotate(txt, txt+1, txt+4);
  61.             }
  62.  
  63.             if(nice[cur] == 0)
  64.             {
  65.                 puts("No");
  66.                 return 0;
  67.             }
  68.             nice[cur]--;
  69.         }
  70.     puts("Yes");
  71.     return 0;
  72. }
  73.  
Add Comment
Please, Sign In to add comment