#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
#define Bismillah ios_base::sync_with_stdio(0);cin.tie(0);
#define indexed_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const int N = 1e5 + 7;
const int INF = 1e18;
const int MOD = 998244353;
int n , m , k;
char a[507][507];
string s;
signed main()
{
Bismillah;
// freopen("closing.in", "r", stdin);
// freopen("closing.out", "w", stdout);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
cin >> a[i][j];
}
}
cin >> s;
int res = 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 yol = 0;
int sz = 0;
while(sz < k && x >= 1 && x <= n && y >= 1 && y <= m && a[x][y] == '.')
{
if(s[sz] == 'N')
{
x--;
sz++;
yol++;
}
else if(s[sz] == 'E')
{
y++;
sz++;
yol++;
}
else if(s[sz] == 'S')
{
x++;
sz++;
yol++;
}
else{
y--;
sz++;
yol++;
}
}
if(yol == k) res++;
}
}
cout << res << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |