#include<bits/stdc++.h>
using namespace std;
bitset<250000> bts,bt,sus,curr;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
string s;
cin>>s;
for(int j=0;j<m;j++) if(s[j]=='#') bts[i*m+j]=0;
else bts[i*m+j]=1;
}
bt=bts;
string t;
cin>>t;
for(auto v:t)
{
curr=0;
if(v=='N'||v=='?')
{
sus=bt;
for(int j=0;j<m;j++) sus[j]=0;
curr|=(sus>>m);
}
if(v=='S'||v=='?')
{
sus=bt;
for(int j=(n-1)*m;j<n*m;j++) sus[j]=0;
curr|=(sus<<m);
}
if(v=='W'||v=='?')
{
sus=bt;
for(int j=0;j<n*m;j+=m) sus[j]=0;
curr|=(sus>>1);
}
if(v=='E'||v=='?')
{
sus=bt;
for(int j=m-1;j<n*m;j+=m) sus[j]=0;
curr|=(sus<<1);
}
bt=curr&bts;
}
cout<<bt.count();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |