forked from pankaj443/CODEFORCES
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path948A.cpp
More file actions
34 lines (31 loc) · 738 Bytes
/
948A.cpp
File metadata and controls
34 lines (31 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,flag=0;
cin>>n>>m;
char a[n+2][m+2];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='S'&&(a[i][j+1]=='W'||a[i][j-1]=='W'||a[i+1][j]=='W'||a[i-1][j]=='W'))
{flag++;break;}
}
}
if(flag>0)
cout<<"NO";
else {
cout<<"YES"<<endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='.')
cout<<'D';
else cout<<a[i][j];
}
cout<<endl;
}
}
return 0;}