#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define F first
#define sz size()
#define S second
#define in insert
#define int long long
#define all(v) v.begin(), v.end()
#define FOR(x, n, m, d) for(int x = n; x <= m; x += d)
#define FORR(x, n, m, d) for(int x = n; x >= m; x -= d)
#define nikita ios_base::sync_with_stdio(0), cin.tie(0);
const int N = 3e5+150;
int n,m,k,tt,ans,l, r, x, y, cnt;
int b[N], c[N], pref[N], block = 448, mod = 1e9+7, a[N], d[N], sum, e[N];
string s[N], str;
bool used[N];
void solve(){
cin >> n >> m >> k;
FOR(i, 1, n, 1)cin >> s[i];
cin >> str;
ans = 0;
FOR(i, 1, n, 1){
FOR(j, 0, m-1, 1){
x = i, y = j;
cnt = 0;
while(s[x][y] != '#' && 1 <= x && x <= n && 0 <= y && y <= m-1 && cnt <= k){
if(str[cnt] == 'N')x--;
else if(str[cnt] == 'S')x++;
else if(str[cnt] == 'E')y ++;
else y --;
cnt ++;
}
if(cnt - 1 == k)ans ++;
}
}
cout << ans;
}
signed main()
{
nikita
tt = 1;
if(!tt)cin >> tt;
FOR(i, 1, tt, 1){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |