#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 105;
const ll inf = 2e9;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const char dirs[] = {'S', 'E', 'N', 'W'};
vector < vector <ll> > dp(M, vector <ll> (M));
ll n, m, ans, len;
string s;
char a[M][M];
int main()
{
cin >> n >> m >> len;
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) cin >> a[i][j], dp[i][j] = 1;
cin >> s;
for(int idx = 0; idx < len; ++idx){
vector < vector <ll> > to(M, vector <ll> (M));
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(a[i][j] != '#')
for(int dir = 0; dir < 4; ++dir) if(s[idx] == '?' || s[idx] == dirs[dir])
to[i + dx[dir]][j + dy[dir]] += dp[i][j];
dp = to;
}
for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) if(a[i][j] != '#') ans += (dp[i][j] > 0);
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
452 KB |
Output is correct |
2 |
Correct |
10 ms |
492 KB |
Output is correct |
3 |
Correct |
14 ms |
488 KB |
Output is correct |
4 |
Correct |
11 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
452 KB |
Output is correct |
2 |
Correct |
10 ms |
492 KB |
Output is correct |
3 |
Correct |
14 ms |
488 KB |
Output is correct |
4 |
Correct |
11 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
15 ms |
484 KB |
Output is correct |
8 |
Correct |
13 ms |
460 KB |
Output is correct |
9 |
Correct |
12 ms |
496 KB |
Output is correct |
10 |
Incorrect |
8 ms |
452 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
452 KB |
Output is correct |
2 |
Correct |
10 ms |
492 KB |
Output is correct |
3 |
Correct |
14 ms |
488 KB |
Output is correct |
4 |
Correct |
11 ms |
492 KB |
Output is correct |
5 |
Correct |
6 ms |
460 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
15 ms |
484 KB |
Output is correct |
8 |
Correct |
13 ms |
460 KB |
Output is correct |
9 |
Correct |
12 ms |
496 KB |
Output is correct |
10 |
Incorrect |
8 ms |
452 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |