#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int r, c, m;
cin >> r >> c >> m;
bitset <505> grid[505], dp[505], pre[505];
for(int i = 1; i <= r; i++){
string s;
cin >> s;
for(int j = 1; j <= c; j++){
if(s[j - 1] == '.'){
grid[i][j] = 1;
dp[i][j] = 1;
pre[i][j] = 1;
}else{
grid[i][j] = 0;
dp[i][j] = 0;
pre[i][j] = 0;
}
//cout << dp[i][j];
}
//cout << '\n';
}
//cout << '\n';
for(int i = 0; i < m; i++){
char ins;
cin >> ins;
switch(ins){
case 'N':
for(int j = 1; j <= r; j++){
dp[j] = pre[j + 1] & grid[j];
}
break;
case 'S':
for(int j = 1; j <= r; j++){
dp[j] = pre[j - 1] & grid[j];
}
break;
case 'W':
for(int j = 1; j <= r; j++){
dp[j] = (pre[j] >> 1) & grid[j];
}
break;
case 'E':
for(int j = 1; j <= r; j++){
dp[j] = (pre[j] << 1) & grid[j];
}
break;
case '?':
for(int j = 1; j <= r; j++){
dp[j] = (pre[j + 1] | pre[j - 1] | (pre[j] << 1) | (pre[j] >> 1)) & grid[j];
}
break;
}
for(int j = 1; j <= r; j++){
pre[j] = dp[j];
}
/*for(int j = 1; j <= r; j++){
for(int k = 1; k <= c; k++){
cout << dp[j][k];
}
cout << '\n';
}
cout << '\n';*/
}
int cnt = 0;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
if(dp[i][j] == 1) cnt++;
}
}
cout << cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
6 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
6 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
106 ms |
384 KB |
Output is correct |
23 |
Correct |
110 ms |
640 KB |
Output is correct |
24 |
Correct |
107 ms |
640 KB |
Output is correct |
25 |
Correct |
104 ms |
768 KB |
Output is correct |
26 |
Correct |
103 ms |
760 KB |
Output is correct |
27 |
Correct |
168 ms |
640 KB |
Output is correct |
28 |
Correct |
171 ms |
764 KB |
Output is correct |
29 |
Correct |
170 ms |
760 KB |
Output is correct |
30 |
Correct |
173 ms |
724 KB |
Output is correct |
31 |
Correct |
167 ms |
640 KB |
Output is correct |
32 |
Correct |
220 ms |
640 KB |
Output is correct |
33 |
Correct |
225 ms |
640 KB |
Output is correct |
34 |
Correct |
219 ms |
640 KB |
Output is correct |
35 |
Correct |
217 ms |
640 KB |
Output is correct |
36 |
Correct |
223 ms |
640 KB |
Output is correct |