#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ff first
#define ss second
using namespace std;
const int N=2*1e5+7;
string a[N];
int main()
{
int n, m, q;
cin >> n >> m >> q;
for (int i=1;i<=n;i++) cin >> a[i];
string s;
cin >> s;
int mx=0, mn=0, mx1=0, mn1=0, res=0, res1=0;
for (int i=0;i<q;i++){
if (s[i] == 'E') res++;
if (s[i] == 'W') res--;
if (s[i] == 'N') res1++;
if (s[i] == 'S') res1--;
mn=min(mn, res);
mx=max(mx, res);
mn1=min(mn1, res1);
mx1=max(mx1, res1);
}
res=res1=0;
ll ans=0;
for (int i=1;i<=n;i++){
for (int j=0;j<m;j++){
res=res1=0;
for (int j1=i-1;j1>0;j1--){
if (a[j1][j] == '.') res++;
else break;
}
if (res+mn1 >= 0){
res=0;
for (int j1=i+1;j1<=n;j1++){
if (a[j1][j] == '.') res++;
else break;
}
if (res >= mx1){
res=0;
for (int j1=j-1;j1>=0;j1--){
if (a[i][j1] == '.') res++;
else break;
}
if (res+mn >= 0){
res=0;
for (int j1=i+1;j1<m;j1++){
if (a[i][j1] == '.') res++;
else break;
}
if (res >= mx) ans++;
}
}
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
6476 KB |
Output is correct |
2 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
6476 KB |
Output is correct |
2 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
6476 KB |
Output is correct |
2 |
Incorrect |
4 ms |
6476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |