이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int r, c, m, ans;
char a[500][500];
string s;
void paths(int x, int y, int far){
if(x < 0 || x >= r || y < 0 || y >= c || a[x][y] == '#') return;
if(far == m){
ans++; return;
}
if(s[far] == 'N') paths(x - 1, y, far + 1);
if(s[far] == 'S') paths(x + 1, y, far + 1);
if(s[far] == 'W') paths(x, y - 1, far + 1);
if(s[far] == 'E') paths(x, y + 1, far + 1);
}
int main(){
cin >> r >> c >> m;
for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) cin >> a[i][j];
cin >> s;
for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) if(a[i][j] != '#') paths(i, j, 0);
cout << ans << '\n';
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |