#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define int long long
using namespace std;
const int mod = 1e9+7;
const ll inf = 1e18;
const int N = 110;
int n,m,k;
char a[105][105];
void solve() {
cin >> n >> m >> k;
for(int i = 1;i<=n;i++) {
for(int j = 1;j<=m;j++) {
cin >> a[i][j];
}
}
string s;
cin >> s;
int ans = 0;
for(int i = 1;i<=n;i++) {
for(int j = 1;j<=m;j++) {
if(a[i][j] == '#') continue;
int x = i, y = j;
int cnt = 0;
while(cnt<k) {
if(s[cnt] == 'N') {
x++;
}
if(s[cnt] == 'S') {
x--;
}
if(s[cnt] == 'W') {
y--;
}
if(s[cnt] == 'E') {
y++;
}
if(x>n || x<=0 || y>m || y<=0 || a[x][y] == '#') break;
cnt++;
}
if(cnt == k) ans++;
}
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt=1;
//cin >> tt;
while(tt--) {
solve();
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |