-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1189.cpp
More file actions
38 lines (35 loc) · 732 Bytes
/
BOJ_1189.cpp
File metadata and controls
38 lines (35 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
int r, c, k;
char arr[6][6];
int visited[6][6];
const int dx[4] = { -1, 1, 0, 0 };
const int dy[4] = { 0, 0, -1, 1 };
int ret = 0;
void solve(int x, int y) {
if (visited[0][c - 1] == k) {
ret++;
return;
}
for (int i = 0; i < 4; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
if (nx < 0 || nx >= r || ny < 0 || ny >= c || visited[nx][ny]) continue;
if (arr[nx][ny] == 'T') continue;
visited[nx][ny] = visited[x][y] + 1;
solve(nx, ny);
visited[nx][ny] = 0;
}
}
int main() {
cin >> r >> c >> k;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
cin >> arr[i][j];
}
}
visited[r - 1][0] = 1;
solve(r - 1, 0);
cout << ret << '\n';
return 0;
}