From 991932b78dd17b8dcf72b6ec54cc81297637d11d Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Sun, 17 Aug 2025 18:38:35 +0900 Subject: [PATCH] =?UTF-8?q?[20250817]=20BOJ=20/=20G3=20/=20=EB=82=B4?= =?UTF-8?q?=EB=A6=AC=EB=A7=89=20=EA=B8=B8/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\246\254\353\247\211 \352\270\270.md" | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 "0224LJH/202508/17 BOJ \353\202\264\353\246\254\353\247\211 \352\270\270.md" diff --git "a/0224LJH/202508/17 BOJ \353\202\264\353\246\254\353\247\211 \352\270\270.md" "b/0224LJH/202508/17 BOJ \353\202\264\353\246\254\353\247\211 \352\270\270.md" new file mode 100644 index 00000000..f2c12dab --- /dev/null +++ "b/0224LJH/202508/17 BOJ \353\202\264\353\246\254\353\247\211 \352\270\270.md" @@ -0,0 +1,75 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static int height,width; + static int[][] arr; + static int[][] dp; + static int[] dy = {-1,0,1,0}; + static int[] dx = {0,1,0,-1}; + + + public static void main(String[] args) throws Exception { + init(); + process(); + print(); + + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + height = Integer.parseInt(st.nextToken()); + width = Integer.parseInt(st.nextToken()); + arr = new int[height][width]; + dp = new int[height][width]; + + for (int i = 0; i < height; i++) { + Arrays.fill(dp[i],-1); + st = new StringTokenizer(br.readLine()); + for (int j = 0; j < width; j++) { + arr[i][j] = Integer.parseInt(st.nextToken()); + } + } + + + } + + public static void process(){ + dfs(0,0); + } + + public static void print(){ + + System.out.println(dp[0][0]); + } + + public static int dfs(int y, int x){ + if ( y == height - 1 && x == width - 1 ) { + return 1; + } + + + if(dp[y][x] != -1) return dp[y][x]; + + dp[y][x] = 0; + + for (int i = 0; i < 4; i++){ + int ny = y + dy[i]; + int nx = x + dx[i]; + if (ny < 0 || ny >= height || nx < 0 || nx >= width) continue; + if (arr[ny][nx] >= arr[y][x]) continue; + + dp[y][x] += dfs(ny, nx); + } + + return dp[y][x]; + + } + +} + + +``` \ No newline at end of file