#include <bits/stdc++.h>
#define ll long long
#define inf INFINITY
#define pb push_back
#define F first
#define S second
const int N = 1e9+7;
using namespace std;
int r,c,m,ans,mx;
char a[10001][10001],b[10001];
void re(int v, int x, int y){
if(a[x][y]=='#'||x<1||y<1||x>r||y>c){
return;
}
if(v==m+1){
ans++;
return;
}
if(b[v]=='E'){
re(v+1,x,y+1);
}
if(b[v]=='W'){
re(v+1,x,y-1);
}
if(b[v]=='S'){
re(v+1,x+1,y);
}
if(b[v]=='N'){
re(v+1,x-1,y);
}
return;
}
int 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>>a[i][j];
}
}
for(int i=1;i<=m;i++){
cin>>b[i];
}
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(a[i][j]!='#'){
re(1,i,j);
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2504 KB |
Output is correct |
6 |
Correct |
1 ms |
2548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2504 KB |
Output is correct |
6 |
Correct |
1 ms |
2548 KB |
Output is correct |
7 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2504 KB |
Output is correct |
6 |
Correct |
1 ms |
2548 KB |
Output is correct |
7 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |