#include <bits/stdc++.h>
// #pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define int long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 26e4;
const int MAXK = 110;
const int INF = 1e9+10;
const int LOG = 19;
const int MOD = 998244353;
const int SQRT = 450;
void chmn(int &a, int b){ a = min(a, b); }
int n, m, k;
bitset <MAXN> ma, ans, te;
signed main(){
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
char x; cin >> x;
if(x=='.') ma[i*(m+1)+j] = 1;
}
}
ans = ma;
string s; cin >> s;
for(int i=0; i<k; i++){
if(s[i]=='?'){
ans = ((ans<<(m+1)) | (ans>>(m+1)) | (ans<<1) | (ans>>1)) & ma;
} else if(s[i]=='E'){
ans = (ans<<1) & ma;
} else if(s[i]=='W'){
ans = (ans>>1) & ma;
} else if(s[i]=='S'){
ans = (ans<<(m+1)) & ma;
} else if(s[i]=='N'){
ans = (ans>>(m+1)) & ma;
}
}
cout << ans.count() << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
3 ms |
604 KB |
Output is correct |
16 |
Correct |
3 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
604 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
764 KB |
Output is correct |
20 |
Correct |
4 ms |
600 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
3 ms |
604 KB |
Output is correct |
16 |
Correct |
3 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
604 KB |
Output is correct |
18 |
Correct |
3 ms |
604 KB |
Output is correct |
19 |
Correct |
3 ms |
764 KB |
Output is correct |
20 |
Correct |
4 ms |
600 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
72 ms |
856 KB |
Output is correct |
23 |
Correct |
83 ms |
1020 KB |
Output is correct |
24 |
Correct |
73 ms |
860 KB |
Output is correct |
25 |
Correct |
72 ms |
1020 KB |
Output is correct |
26 |
Correct |
72 ms |
856 KB |
Output is correct |
27 |
Correct |
132 ms |
1020 KB |
Output is correct |
28 |
Correct |
116 ms |
860 KB |
Output is correct |
29 |
Correct |
109 ms |
856 KB |
Output is correct |
30 |
Correct |
116 ms |
856 KB |
Output is correct |
31 |
Correct |
113 ms |
860 KB |
Output is correct |
32 |
Correct |
144 ms |
1024 KB |
Output is correct |
33 |
Correct |
135 ms |
860 KB |
Output is correct |
34 |
Correct |
140 ms |
968 KB |
Output is correct |
35 |
Correct |
134 ms |
1024 KB |
Output is correct |
36 |
Correct |
141 ms |
860 KB |
Output is correct |