#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
bool dp[maxn][maxn][maxn];
bool tab[maxn][maxn];
int r, c, m;
string dir;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>r>>c>>m;
for(int i=1;i<=r;i++) {
for(int j=1;j<=c;j++) {
char z;
cin>>z;
tab[i][j] = (z != '#');
dp[i][j][m] = (z != '#');
}
}
cin>>dir;
reverse(dir.begin(),dir.end());
int sol = 0;
for(int k=m-1;k>=0;k--) {
for(int i=1;i<=r;i++) {
for(int j=1;j<=c;j++) {
map<char,bool> most;
most['S'] = dp[i-1][j][k+1];
most['N'] = dp[i+1][j][k+1];
most['W'] = dp[i][j+1][k+1];
most['E'] = dp[i][j-1][k+1];
most['?'] = most['N'] || most['S'] || most['E'] || most['W'];
dp[i][j][k] = (most[dir[k]] && tab[i][j]);
if(k == 0 && dp[i][j][k]) sol++;
}
}
}
cout<<sol<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
1492 KB |
Output is correct |
2 |
Correct |
274 ms |
1408 KB |
Output is correct |
3 |
Correct |
278 ms |
1408 KB |
Output is correct |
4 |
Correct |
290 ms |
1528 KB |
Output is correct |
5 |
Correct |
279 ms |
1528 KB |
Output is correct |
6 |
Correct |
273 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
1492 KB |
Output is correct |
2 |
Correct |
274 ms |
1408 KB |
Output is correct |
3 |
Correct |
278 ms |
1408 KB |
Output is correct |
4 |
Correct |
290 ms |
1528 KB |
Output is correct |
5 |
Correct |
279 ms |
1528 KB |
Output is correct |
6 |
Correct |
273 ms |
1408 KB |
Output is correct |
7 |
Correct |
265 ms |
1408 KB |
Output is correct |
8 |
Correct |
290 ms |
1528 KB |
Output is correct |
9 |
Correct |
288 ms |
1528 KB |
Output is correct |
10 |
Correct |
271 ms |
1408 KB |
Output is correct |
11 |
Correct |
279 ms |
1408 KB |
Output is correct |
12 |
Correct |
281 ms |
1408 KB |
Output is correct |
13 |
Correct |
294 ms |
1408 KB |
Output is correct |
14 |
Correct |
298 ms |
1408 KB |
Output is correct |
15 |
Correct |
277 ms |
1528 KB |
Output is correct |
16 |
Correct |
285 ms |
1408 KB |
Output is correct |
17 |
Correct |
267 ms |
1408 KB |
Output is correct |
18 |
Correct |
269 ms |
1408 KB |
Output is correct |
19 |
Correct |
293 ms |
1528 KB |
Output is correct |
20 |
Correct |
282 ms |
1408 KB |
Output is correct |
21 |
Correct |
277 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
268 ms |
1492 KB |
Output is correct |
2 |
Correct |
274 ms |
1408 KB |
Output is correct |
3 |
Correct |
278 ms |
1408 KB |
Output is correct |
4 |
Correct |
290 ms |
1528 KB |
Output is correct |
5 |
Correct |
279 ms |
1528 KB |
Output is correct |
6 |
Correct |
273 ms |
1408 KB |
Output is correct |
7 |
Correct |
265 ms |
1408 KB |
Output is correct |
8 |
Correct |
290 ms |
1528 KB |
Output is correct |
9 |
Correct |
288 ms |
1528 KB |
Output is correct |
10 |
Correct |
271 ms |
1408 KB |
Output is correct |
11 |
Correct |
279 ms |
1408 KB |
Output is correct |
12 |
Correct |
281 ms |
1408 KB |
Output is correct |
13 |
Correct |
294 ms |
1408 KB |
Output is correct |
14 |
Correct |
298 ms |
1408 KB |
Output is correct |
15 |
Correct |
277 ms |
1528 KB |
Output is correct |
16 |
Correct |
285 ms |
1408 KB |
Output is correct |
17 |
Correct |
267 ms |
1408 KB |
Output is correct |
18 |
Correct |
269 ms |
1408 KB |
Output is correct |
19 |
Correct |
293 ms |
1528 KB |
Output is correct |
20 |
Correct |
282 ms |
1408 KB |
Output is correct |
21 |
Correct |
277 ms |
1408 KB |
Output is correct |
22 |
Runtime error |
8 ms |
3084 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
23 |
Halted |
0 ms |
0 KB |
- |