#include<bits/stdc++.h>
using namespace std;
const int mx=105;
typedef long long ll;
int mod=998244353 ;
const int MXm=22;
#define F first
#define S second
const int inf=1e9+10;
bitset<mx> dp[mx];
bitset<mx> dp2[mx];//the previous
bitset<mx>row[mx];
char ss[mx][mx];
string s;
void solve(){
int n,m,k;
cin>>n>>m>>k;
for(int i =0;i<n;i++){
for(int j=0;j<m;j++){
cin>>ss[i][j];
if(ss[i][j]=='.'){
dp[i][j]=1;
row[i][j]=1;
}
}
}
cin>>s;
for(int i=1;i<=k;i++){
for(int i=0;i<n;i++){
dp2[i]=dp[i];
dp[i]&=0;
}
if(s[i-1]=='N'||s[i-1]=='?'){
for(int j=0;j<n;j++){
dp[j]|=(dp2[j+1]&row[j]);
}
}
if(s[i-1]=='S'||s[i-1]=='?'){
for(int j=1;j<n;j++){
dp[j]|=(dp2[j-1]&row[j]);
}
}
if(s[i-1]=='E'||s[i-1]=='?'){
for(int j=0;j<n;j++){
dp[j]|=((dp2[j]<<1)&row[j]);
}
}
if(s[i-1]=='W'||s[i-1]=='?'){
for(int j=0;j<n;j++){
dp[j]|=((dp2[j]>>1)&row[j]);
}
}
}
ll ans=0;
for(int i =0;i<n;i++){
ans+=dp[i].count();
}
cout<<ans;
return;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;t=1;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
328 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
328 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Runtime error |
2 ms |
716 KB |
Execution killed with signal 11 |
23 |
Halted |
0 ms |
0 KB |
- |