fork download
  1. /*
  2. *************************************************************************
  3. * $ Author : honeyslawyer $
  4. * $ Name : shashank gupta $
  5. *************************************************************************
  6. *
  7. * Copyright 2013 @ honeyslawyer and shashank gupta
  8. *
  9. ************************************************************************/
  10. #include<cstdio>
  11. #include<iostream>
  12. #include<cmath>
  13. //#include<conio.h>
  14. #include<cstring>
  15. #include<ctype.h>
  16. #include<algorithm>
  17. #include<vector>
  18. #include<stdlib.h>
  19. #include<map>
  20. #include<queue>
  21. #include<stack>
  22. #include<set>
  23. #include<string>
  24. #include<climits>
  25.  
  26. #define mod 1000000007
  27. #define ll long long
  28.  
  29. using namespace std;
  30. ll gcd(ll a,ll b) {if(b==0) return a; return gcd(b,a%b);}
  31.  
  32. ll power(ll b,ll exp,ll m)
  33. {ll ans=1;
  34. b%=m;
  35. while(exp)
  36. {if(exp&1)
  37. ans=(ans*b)%m;
  38. exp>>=1;
  39. b=(b*b)%m;
  40. }
  41. return ans;
  42. }
  43. char a[400][400];
  44. int main()
  45. {
  46. int n;
  47. char b;
  48. scanf("%d",&n);
  49. scanf("%c",&b);
  50.  
  51. for(int i=0;i<n;i++)
  52. gets(a[i]);
  53.  
  54. for(int i=1;i<n-1;i++)
  55. {
  56. for(int j=1;j<n-1;j++)
  57. {
  58. if(a[i][j]=='#')
  59. {
  60. if(a[i-1][j]=='#'&&a[i+1][j]=='#'&&a[i][j-1]=='#'&&a[i][j+1]=='#')
  61. {
  62. a[i][j]='.';
  63. a[i-1][j]='.';
  64. a[i+1][j]='.';
  65. a[i][j-1]='.';
  66. a[i][j+1]='.';
  67. }
  68. }
  69. }
  70. }
  71. for(int i=0;i<n;i++)
  72. {
  73. for(int j=0;j<n;j++)
  74. {
  75. if(a[i][j]=='#')
  76. {
  77. printf("NO\n");
  78. return 0;
  79. }
  80. }
  81. }
  82. printf("YES\n");
  83.  
  84. //getch();
  85. return 0;
  86. /*checklist
  87. 1)getch() and conio.h removed.*/
  88. }
  89.  
Success #stdin #stdout 0s 3456KB
stdin
5
.#...
####.
.####
...#.
.....
stdout
YES