Advertisement
amine99

Untitled

Mar 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define loop(i,b,e) for(auto i=b;i<=e;i++)
  5. #define reloop(i,e,b) for(auto i=e;i>=b;i--)
  6. #define all(x) x.begin(),x.end()
  7. #define ll long long
  8. #define pb push_back
  9. #define mp make_pair
  10. #define fi first
  11. #define se second
  12. #define pf printf
  13. #define sf scanf
  14.  
  15. int r,c;
  16. char x,m[501][501];
  17.  
  18. int main()
  19. {
  20.    cin >> r >> c;
  21.    loop(i,0,r-1) {
  22.       loop(j,0,c-1) {
  23.          cin >> m[i][j];
  24.          if(m[i][j] == '.')
  25.             m[i][j] = 'D';
  26.       }
  27.    }
  28.    loop(i,0,r-1) {
  29.       loop(j,0,c-1) {
  30.          if(m[i][j] == 'W') {
  31.             if(m[i+1][j] == 'S' || m[i-1][j] == 'S' || m[i][j+1] == 'S' || m[i][j-1] == 'S') {
  32.                pf("No");
  33.                return 0;
  34.             }
  35.          }
  36.       }
  37.    }
  38.    pf("Yes\n");
  39.    loop(i,0,r-1) {
  40.       loop(j,0,c-1)
  41.          pf("%c",m[i][j]);
  42.       pf("\n");
  43.    }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement