Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int R,C,i,j,check=0;
- char a[500][500];
- cin>>R>>C;
- for(i=0;i<R;i++)
- {
- for(j=0;j<C;j++)
- {
- cin>>a[i][j];
- }
- }
- for(i=0;i<R;i++)
- {
- for(j=0;j<C;j++)
- {
- if(a[i][j]=='W')
- {
- if(a[i-1][j]=='S'||a[i+1][j]=='S'||a[i][j-1]=='S'||a[i][j+1]=='S')
- {
- cout<<"No";
- check=1;
- break;
- }
- }
- }
- if(check==1)
- break;
- }
- if(check==0)
- {
- for(i=0;i<R;i++)
- {
- for(j=0;j<C;j++)
- {
- if(a[i][j]=='.')
- a[i][j]='D';
- }
- }
- cout<<"Yes"<<endl;
- for(i=0;i<R;i++)
- {
- for(j=0;j<C;j++)
- {
- cout<<a[i][j];
- }
- cout<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement