This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 502
#define M 5001
char a[N][N];
bool dp[N][N][M];
void solve(){
char r;
int n,m,o,s;
cin>>n>>m>>o;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
dp[i][j][0]=(a[i][j]=='.');
}
}
s=0;
for(int k=1;k<=o;k++){
cin>>r;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='#') continue;
if(r=='?'){
if(dp[i+1][j][k-1]) dp[i][j][k]=1;
if(dp[i][j-1][k-1]) dp[i][j][k]=1;
if(dp[i-1][j][k-1]) dp[i][j][k]=1;
if(dp[i][j+1][k-1]) dp[i][j][k]=1;
}
if(r=='N' && dp[i+1][j][k-1])
dp[i][j][k]=1;
if(r=='E' && dp[i][j-1][k-1])
dp[i][j][k]=1;
if(r=='S' && dp[i-1][j][k-1])
dp[i][j][k]=1;
if(r=='W' && dp[i][j+1][k-1])
dp[i][j][k]=1;
if(dp[i][j][o]) s++;
}
}
}
cout<<s;
}
int main(){
L0TA;
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... |