#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> pt;
typedef pair<int, int> pii;
#define x() real()
#define y() imag()
#define smx(a, b) a = max(a, b)
#define smn(a, b) a = min(a, b)
#define in(mp, v) (mp.find(v) != mp.end())
#define iter(var, n) for (int var = 0; var < n; var++)
const int MAXN = 502;
const int MOD = 1000000007;
typedef bitset<501> bst;
vector<bst> def, cur;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int r, c, m; cin >> r >> c >> m;
def.resize(r);
iter(i, r) {
string s; cin >> s;
iter(j, c) {
def[i][j] = s[j] == '.';
}
}
cur = def;
string ms; cin >> ms;
iter(mi, m) {
char d = ms[mi];
vector<bst> ncur(r);
if (d == 'N') {
iter(i, r-1) {
ncur[i] = cur[i+1] & def[i];
}
} else if (d == 'E') {
iter(i, r) {
ncur[i] = (cur[i] << 1) & def[i];
}
} else if (d == 'S') {
iter(i, r-1) {
ncur[i+1] = cur[i] & def[i+1];
}
} else if (d == 'W') {
iter(i, r) {
ncur[i] = (cur[i] >> 1) & def[i];
}
} else {
iter(i, r) {
ncur[i] = (cur[i] << 1) | (cur[i] >> 1);
if (i > 0) ncur[i] |= cur[i-1];
if (i < r-1) ncur[i] |= cur[i+1];
ncur[i] &= def[i];
}
}
cur = ncur;
}
int ans = 0;
iter(i, r) {
ans += cur[i].count();
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
2 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
110 ms |
748 KB |
Output is correct |
23 |
Correct |
119 ms |
768 KB |
Output is correct |
24 |
Correct |
105 ms |
768 KB |
Output is correct |
25 |
Correct |
105 ms |
876 KB |
Output is correct |
26 |
Correct |
103 ms |
876 KB |
Output is correct |
27 |
Correct |
140 ms |
748 KB |
Output is correct |
28 |
Correct |
152 ms |
748 KB |
Output is correct |
29 |
Correct |
168 ms |
696 KB |
Output is correct |
30 |
Correct |
154 ms |
768 KB |
Output is correct |
31 |
Correct |
146 ms |
768 KB |
Output is correct |
32 |
Correct |
171 ms |
876 KB |
Output is correct |
33 |
Correct |
183 ms |
768 KB |
Output is correct |
34 |
Correct |
182 ms |
788 KB |
Output is correct |
35 |
Correct |
172 ms |
768 KB |
Output is correct |
36 |
Correct |
171 ms |
748 KB |
Output is correct |