This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define fort(x , y) for(int y = 1 ; y <= x ; y++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define int long long
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const int NN = 1e9 + 7;
int r,c,m,k;
char s[501][501];
string p;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> r >> c >> m;
for(int i = 1 ; i <= r ; i++){
for(int j = 1 ; j <= c ; j++){
cin >> s[i][j];
}
}
cin >> p;
p = '#' + p;
int ans = 0;
for(int i = 1 ; i <= r ; i++){
for(int j = 1 ; j <= c ; j++){
bool oknt = 0;
if(s[i][j] == '#'){
continue;
}
int now1 = i , now2 = j;
for(int u = 1 ; u <= m ; u++){
if(p[u] == '?'){
continue;
}
if(p[u] == 'N'){
if(s[now1 - 1][now2] != '.'){
oknt = 1;
break;
}
now1--;
}
if(p[u] == 'E'){
if(s[now1][now2 + 1] != '.'){
oknt = 1;
break;
}
now2++;
}
if(p[u] == 'S'){
if(s[now1 + 1][now2] != '.'){
oknt = 1;
break;
}
now1++;
}
if(p[u] == 'W'){
if(s[now1][now2 - 1] != '.'){
oknt = 1;
break;
}
now2--;
}
}
if(oknt == 0){
ans ++;
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |