Advertisement
Jahid_Hasan

948 A

Mar 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int R,C,i,j,check=0;
  7. char a[500][500];
  8. cin>>R>>C;
  9. for(i=0;i<R;i++)
  10. {
  11. for(j=0;j<C;j++)
  12. {
  13. cin>>a[i][j];
  14. }
  15. }
  16.  
  17. for(i=0;i<R;i++)
  18. {
  19. for(j=0;j<C;j++)
  20. {
  21. if(a[i][j]=='W')
  22. {
  23. if(a[i-1][j]=='S'||a[i+1][j]=='S'||a[i][j-1]=='S'||a[i][j+1]=='S')
  24. {
  25. cout<<"No";
  26. check=1;
  27. break;
  28. }
  29. }
  30. }
  31. if(check==1)
  32. break;
  33. }
  34.  
  35. if(check==0)
  36. {
  37. for(i=0;i<R;i++)
  38. {
  39. for(j=0;j<C;j++)
  40. {
  41. if(a[i][j]=='.')
  42. a[i][j]='D';
  43. }
  44. }
  45. cout<<"Yes"<<endl;
  46. for(i=0;i<R;i++)
  47. {
  48. for(j=0;j<C;j++)
  49. {
  50. cout<<a[i][j];
  51. }
  52. cout<<endl;
  53. }
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement