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 suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n,m,q;
string s[105];
string que;
void solve(){
cin>>n>>m>>q;
for(int i=0;i<n;i++) cin>>s[i];
cin>>que;
ll cnt=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
ll x,y,idx;
x=i,y=j,idx=0;
while(x<n&&x>-1&&y<m&&y>-1&&s[x][y]!='#'&&idx<q){
if(que[idx]=='W') x--;
else if(que[idx]=='S') x++;
else if(que[idx]=='E') y++;
else y--;
}
if(idx==q) cnt++;
}
}
co cnt<<'\n';
}
int main()
{
suiii
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... |