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>
using namespace std;
const int nx=105;
int r, c, m, dx[4]={1, 0, 0, -1}, dy[4]={0, 1, -1, 0}, en[100], cnt;
char mp[nx][nx];
bool dp[nx][nx][nx];
string s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
en['N']=1; en['W']=0; en['E']=3; en['S']=2;
cin>>r>>c>>m;
for (int i=1; i<=r; i++) for (int j=1; j<=c; j++) cin>>mp[i][j], dp[0][i][j]=(mp[i][j]=='.');
cin>>s;
for (int i=1; i<=m; i++)
{
for (int j=1; j<=r; j++)
{
for (int k=1; k<=c; k++)
{
if (mp[j][k]!='#')
{
if (s[i-1]=='?') for (int l=0; l<4; l++) dp[i][j][k]|=dp[i-1][j+dy[l]][k+dx[l]];
else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
}
if (i==m&&dp[i][j][k]) cnt++;
//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
}
}
}
cout<<cnt;
}
Compilation message (stderr)
nautilus.cpp: In function 'int main()':
nautilus.cpp:27:60: warning: array subscript has type 'char' [-Wchar-subscripts]
27 | else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
| ^
nautilus.cpp:27:78: warning: array subscript has type 'char' [-Wchar-subscripts]
27 | else dp[i][j][k]=dp[i-1][j+dy[en[s[i-1]]]][k+dx[en[s[i-1]]]];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |