/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 510;
int n, m, l;
bitset < maxn > bt[maxn], base[maxn], cur[maxn], pos[maxn];
void go_north()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = bt[i + 1];
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_south()
{
for (int i = 1; i <= n + 1; i ++)
pos[i] = bt[i - 1];
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_east()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = (bt[i] << 1);
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void go_west()
{
for (int i = 0; i <= n + 1; i ++)
pos[i] = (bt[i] >> 1);
for (int i = 0; i <= n + 1; i ++)
cur[i] = (cur[i] | pos[i]);
}
void solve()
{
cin >> n >> m >> l;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
{
char c;
cin >> c;
if (c == '.')
bt[i][j] = 1, base[i][j] = 1;
}
for (int t = 1; t <= l; t ++)
{
for (int i = 0; i <= n + 1; i ++)
cur[i].reset();
char c;
cin >> c;
if (c == 'N' || c =='?')
go_north();
if (c == 'E' || c == '?')
go_east();
if (c == 'S' || c == '?')
go_south();
if (c == 'W' || c == '?')
go_west();
/**for (int i = 1; i <= n; i ++, cout << endl)
for (int j = 1; j <= m; j ++)
cout << bt[i][j];
cout << "---------------" << endl;*/
for (int i = 0; i <= n + 1; i ++)
bt[i] = cur[i], bt[i] = (bt[i] & base[i]);
}
int ans = 0;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= m; j ++)
ans += bt[i][j];
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
304 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
304 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
304 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
2 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
165 ms |
408 KB |
Output is correct |
23 |
Correct |
140 ms |
572 KB |
Output is correct |
24 |
Correct |
136 ms |
660 KB |
Output is correct |
25 |
Correct |
151 ms |
724 KB |
Output is correct |
26 |
Correct |
141 ms |
640 KB |
Output is correct |
27 |
Correct |
189 ms |
672 KB |
Output is correct |
28 |
Correct |
219 ms |
660 KB |
Output is correct |
29 |
Correct |
212 ms |
656 KB |
Output is correct |
30 |
Correct |
192 ms |
660 KB |
Output is correct |
31 |
Correct |
192 ms |
560 KB |
Output is correct |
32 |
Correct |
238 ms |
656 KB |
Output is correct |
33 |
Correct |
251 ms |
656 KB |
Output is correct |
34 |
Correct |
252 ms |
656 KB |
Output is correct |
35 |
Correct |
251 ms |
656 KB |
Output is correct |
36 |
Correct |
253 ms |
632 KB |
Output is correct |