fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int M=1e9+7;
  5.  
  6. #define rep(i,a,b) for(int i = a; i < b; i++)
  7. #define fr(a,b) for(int i = a; i < b; i++)
  8. #define all(x) (x).begin(),(x).end()
  9. #define ll long long int
  10.  
  11. void rotate(vector<vector<int>>& v) {
  12. rep(i,0,4){
  13. rep(j,0,4) swap(v[i][j],v[j][i]);
  14. }
  15. rep(i,0,4) reverse(all(v[i]));
  16. }
  17.  
  18. int main() {
  19. ios::sync_with_stdio(false);
  20. cin.tie(0);
  21.  
  22. vector<vector<int>> x(4,vector<int> (4,0)),y(4,vector<int> (4,0)),z(4,vector<int> (4,0));
  23. rep(i,0,4){
  24. rep(j,0,4){
  25. char ch;cin>>ch;
  26. if(ch=='#') x[i][j]=1;
  27. else x[i][j]=0;
  28. }
  29. }
  30. rep(i,0,4){
  31. rep(j,0,4){
  32. char ch;cin>>ch;
  33. if(ch=='#') y[i][j]=1;
  34. else y[i][j]=0;
  35. }
  36. }
  37. rep(i,0,4){
  38. rep(j,0,4){
  39. char ch;cin>>ch;
  40. if(ch=='#') z[i][j]=1;
  41. else z[i][j]=0;
  42. }
  43. }
  44. // rotate(x);
  45. // rep(i,0,4){
  46. // rep(j,0,4) cout<<x[i][j];
  47. // cout<<endl;
  48. // }
  49. string ans="No";
  50. for(int ct1=0;ct1<4;ct1++){
  51. vector<vector<int>> temp=x;
  52. rotate(y);
  53. int ct=1;
  54. rep(i,0,4){
  55. rep(j,0,4){
  56. temp[i][j]+=y[i][j];
  57. if(temp[i][j]>1){ct=0;break;}
  58. }
  59. if(ct==0) break;
  60. }
  61. if(ct==0) continue;
  62. for(int ct2=0;ct2<4;ct2++){
  63. rotate(z);
  64. int ct=1;
  65. rep(i,0,4){
  66. rep(j,0,4){
  67. temp[i][j]+=z[i][j];
  68. if(temp[i][j]>1){ct=0;break;}
  69. }
  70. if(ct==0) break;
  71. }
  72. if(ct==0) continue;
  73. rep(i,0,4){
  74. rep(j,0,4){
  75. // temp[i][j]+=z[i][j];
  76. if(temp[i][j]!=1){ct=0;break;}
  77. }
  78. if(ct==0) break;
  79. }
  80. if(ct){ans="Yes";break;}
  81. }
  82. if(ans=="Yes") break;
  83. }
  84. cout<<ans;
  85.  
  86. return 0;
  87. }
Success #stdin #stdout 0.01s 5408KB
stdin
###.
.##.
..#.
.###
....
...#
..##
...#
....
#...
#...
#...
stdout
No