#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map>
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
signed main(){
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int r,c,m; cin>>r>>c>>m;
bitset<500> a[500],dp[500];
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
char c; cin>>c;
if(c=='#'){
a[i][j]=0;
}else{
a[i][j]=1;
dp[i][j]=1;
}
}
}
string s; cin>>s;
for(int k=m-1; k>=0; k--){
if(s[k]=='E'){
for(int i=0; i<r; i++){
dp[i]=(a[i]&(dp[i]>>1));
}
}else if(s[k]=='S'){
for(int i=0; i<r-1; i++){
dp[i]=(a[i]&dp[i+1]);
}
}else if(s[k]=='W'){
for(int i=0; i<r; i++){
dp[i]=(a[i]&(dp[i]<<1));
}
}else if(s[k]=='N'){
for(int i=r-1; i>0; i--){
dp[i]=(a[i]&dp[i-1]);
}
}else{
bitset<500> tmp[500];
for(int i=0; i<r; i++){
tmp[i]|=(a[i]&(dp[i]>>1));
}
for(int i=0; i<r-1; i++){
tmp[i]|=(a[i]&dp[i+1]);
}
for(int i=0; i<r; i++){
tmp[i]|=(a[i]&(dp[i]<<1));
}
for(int i=r-1; i>0; i--){
tmp[i]|=(a[i]&dp[i-1]);
}
for(int i=0; i<r; i++){
dp[i]=tmp[i];
}
}
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
cout<<dp[i][j];
}
cout<<endl;
}
return 0;
}
int ans=0;
for(int i=0; i<r; i++){
for(int j=0; j<c; j++){
if(dp[i][j]==1) ans++;
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |