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 int long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define sz size()
#define vi vector<int>
#define bk back()
#define fr front()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define itn int
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=5010,mod=1e9+7;
/*
20.12.23
WEDNESDAY
*/
void at(bool ok){
if(ok) cout<<"YES\n";
else cout<<"NO\n";
}
char a[maxn][maxn];
int n,m,k;
string s;
int real(int i,int j){
if(a[i][j]!='.')return 0;
for(int i=0;i<s.size();i++){
if(s[i]=='W') j--;
if(s[i]=='E') j++;
if(s[i]=='N') i--;
else i++;
if(i>n||j>m||i<1||j<1||a[i][j]!='.') return 0;
}
return 1;
}
void solve(){
cin>>n>>m>>k;
for(int i=1;i<=n;i++){
string x;cin>>x;
for(int j=0;j<m;j++){
a[i][j+1]=x[j];
}
}
cin>>s;
int ans=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
ans+=real(i,j);
}
cout<<ans<<'\n';
}
signed main(){
//freopen("A.in","r",stdin),freopen("A.out","w",stdout);
ios_base::sync_with_stdio(0);cin.tie(0);
int T=1;
// cin>>T;
for(int i=1;i<=T;i++){
// cout<<"Case #"<<i<<": ";
solve();
}
}
Compilation message (stderr)
nautilus.cpp: In function 'long long int real(long long int, long long int)':
nautilus.cpp:35:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |