#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
const int sz = 500*500;
signed main(){
cin.tie(0)->sync_with_stdio(0);
int r, c, m; cin >> r >> c >> m;
char inp;
bitset<sz> a, b, x, y, g;
for(int i=0; i<r; ++i){
for(int j=0; j<c; ++j){
cin >> inp;
g[i*c+j] = b[i*c+j] = (inp == '.');
x[i*c+j] = j!=0;
y[i*c+j] = j!=c-1;
}
}
string s; cin >> s;
for(int k=0; k<m; ++k){
a = b;
b = bitset<sz>(0);
if(s[k] == 'S' or s[k] == '?') b |= (a << c);
if(s[k] == 'N' or s[k] == '?') b |= (a >> c);
if(s[k] == 'E' or s[k] == '?') b |= (a << 1) & x;
if(s[k] == 'W' or s[k] == '?') b |= (a >> 1) & y;
b = b & g;
}
int res = 0;
for(int i=0; i<r; ++i)
for(int j=0; j<c; ++j)
res += b[i*c+j];
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
460 KB |
Output is correct |
2 |
Correct |
3 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
460 KB |
Output is correct |
2 |
Correct |
3 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
3 ms |
460 KB |
Output is correct |
8 |
Correct |
3 ms |
460 KB |
Output is correct |
9 |
Correct |
4 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
460 KB |
Output is correct |
11 |
Correct |
4 ms |
448 KB |
Output is correct |
12 |
Correct |
4 ms |
460 KB |
Output is correct |
13 |
Correct |
5 ms |
460 KB |
Output is correct |
14 |
Correct |
5 ms |
460 KB |
Output is correct |
15 |
Correct |
5 ms |
460 KB |
Output is correct |
16 |
Correct |
5 ms |
460 KB |
Output is correct |
17 |
Correct |
5 ms |
460 KB |
Output is correct |
18 |
Correct |
5 ms |
460 KB |
Output is correct |
19 |
Correct |
5 ms |
448 KB |
Output is correct |
20 |
Correct |
5 ms |
452 KB |
Output is correct |
21 |
Correct |
5 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
460 KB |
Output is correct |
2 |
Correct |
3 ms |
460 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
3 ms |
460 KB |
Output is correct |
8 |
Correct |
3 ms |
460 KB |
Output is correct |
9 |
Correct |
4 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
460 KB |
Output is correct |
11 |
Correct |
4 ms |
448 KB |
Output is correct |
12 |
Correct |
4 ms |
460 KB |
Output is correct |
13 |
Correct |
5 ms |
460 KB |
Output is correct |
14 |
Correct |
5 ms |
460 KB |
Output is correct |
15 |
Correct |
5 ms |
460 KB |
Output is correct |
16 |
Correct |
5 ms |
460 KB |
Output is correct |
17 |
Correct |
5 ms |
460 KB |
Output is correct |
18 |
Correct |
5 ms |
460 KB |
Output is correct |
19 |
Correct |
5 ms |
448 KB |
Output is correct |
20 |
Correct |
5 ms |
452 KB |
Output is correct |
21 |
Correct |
5 ms |
460 KB |
Output is correct |
22 |
Correct |
123 ms |
588 KB |
Output is correct |
23 |
Correct |
124 ms |
588 KB |
Output is correct |
24 |
Correct |
123 ms |
588 KB |
Output is correct |
25 |
Correct |
123 ms |
584 KB |
Output is correct |
26 |
Correct |
120 ms |
588 KB |
Output is correct |
27 |
Correct |
168 ms |
588 KB |
Output is correct |
28 |
Correct |
172 ms |
588 KB |
Output is correct |
29 |
Correct |
171 ms |
588 KB |
Output is correct |
30 |
Correct |
173 ms |
588 KB |
Output is correct |
31 |
Correct |
167 ms |
708 KB |
Output is correct |
32 |
Correct |
207 ms |
588 KB |
Output is correct |
33 |
Correct |
211 ms |
588 KB |
Output is correct |
34 |
Correct |
207 ms |
588 KB |
Output is correct |
35 |
Correct |
206 ms |
600 KB |
Output is correct |
36 |
Correct |
206 ms |
708 KB |
Output is correct |