From 1e9c81ff626e4d7b4597886352cf7450b1eca117 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Thu, 16 Jul 2026 15:57:15 +0900 Subject: [PATCH 1/2] =?UTF-8?q?17070=20:=20=ED=8C=8C=EC=9D=B4=ED=94=84=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B01=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week7/BOJ17070/BOJ17070_V1.cpp | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/week7/BOJ17070/BOJ17070_V1.cpp diff --git a/src/week7/BOJ17070/BOJ17070_V1.cpp b/src/week7/BOJ17070/BOJ17070_V1.cpp new file mode 100644 index 0000000..0e08ecc --- /dev/null +++ b/src/week7/BOJ17070/BOJ17070_V1.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; +int N; +int arr[16][16]; +vector> dirs = {{0,1}, {1,0}, {1,1}}; +int dfs(int y, int x, int direction) { + if (y == N-1 && x == N-1) return 1; + + int ret = 0; + for (int i=0; i<3; i++) { + int ny = y + dirs[i].first; + int nx = x + dirs[i].second; + if (ny >= N || nx >= N) continue; + if (dirs[i].first == 1 && dirs[i].second == 1) { + if (arr[ny][x] || arr[y][nx] || arr[ny][nx]) continue; + } else { + if (arr[ny][nx]) continue; + if (direction == 0 && dirs[i].first == 1 && dirs[i].second == 0) continue; + if (direction == 1 && dirs[i].first == 0 && dirs[i].second == 1) continue; + } + + ret += dfs(ny, nx, i); + } + + return ret; +} +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> N; + for (int i=0; i> arr[i][j]; + } + } + + + + cout << dfs(0,1,0); + + return 0; +} \ No newline at end of file From 1897dd5b6001846a63d7b9ba8fb748b3d009abb9 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Thu, 16 Jul 2026 16:08:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?17070=20:=20=ED=8C=8C=EC=9D=B4=ED=94=84=20?= =?UTF-8?q?=EC=98=AE=EA=B8=B0=EA=B8=B01=20V2=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week7/BOJ17070/BOJ17070_V2.cpp | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/week7/BOJ17070/BOJ17070_V2.cpp diff --git a/src/week7/BOJ17070/BOJ17070_V2.cpp b/src/week7/BOJ17070/BOJ17070_V2.cpp new file mode 100644 index 0000000..9bd2b92 --- /dev/null +++ b/src/week7/BOJ17070/BOJ17070_V2.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +int N; +int arr[16][16]; +int dp[16][16][3]; +vector> dirs = {{0,1}, {1,0}, {1,1}}; +int dfs(int y, int x, int direction) { + if (y == N-1 && x == N-1) return 1; + + int &ret = dp[y][x][direction]; + if (ret != -1) return ret; + + int cnt = 0; + for (int i=0; i<3; i++) { + int ny = y + dirs[i].first; + int nx = x + dirs[i].second; + if (ny >= N || nx >= N) continue; + if (dirs[i].first == 1 && dirs[i].second == 1) { + if (arr[ny][x] || arr[y][nx] || arr[ny][nx]) continue; + } else { + if (arr[ny][nx]) continue; + if (direction == 0 && dirs[i].first == 1 && dirs[i].second == 0) continue; + if (direction == 1 && dirs[i].first == 0 && dirs[i].second == 1) continue; + } + + cnt += dfs(ny, nx, i); + } + + return ret = cnt; +} +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + cin >> N; + for (int i=0; i> arr[i][j]; + } + } + + + memset(dp, -1, sizeof(dp)); + cout << dfs(0,1,0); + + return 0; +} \ No newline at end of file