From d359503141835682fac37ad43c1ea924ad79fcd9 Mon Sep 17 00:00:00 2001 From: HeeEul Shin <83682424+ShinHeeEul@users.noreply.github.com> Date: Thu, 20 Mar 2025 19:13:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Rename=2020=20BOJ=20G5=204=EC=99=80=207=20t?= =?UTF-8?q?o=2020=20BOJ=20G5=204=EC=99=80=207.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../202503/20 BOJ G5 4\354\231\200 7.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7" => "ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7.md" (100%) diff --git "a/ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7" "b/ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7.md" similarity index 100% rename from "ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7" rename to "ShinHeeEul/202503/20 BOJ G5 4\354\231\200 7.md" From 95f4fc6a2fb317ff0ef74f64b7ffba1f1071d545 Mon Sep 17 00:00:00 2001 From: HeeEul Shin <83682424+ShinHeeEul@users.noreply.github.com> Date: Fri, 4 Apr 2025 23:29:54 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[20250404]=20BOJ=20/=20G4=20/=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=B4=ED=94=84=20=EC=98=AE=EA=B8=B0=EA=B8=B02=20/=20?= =?UTF-8?q?=EC=8B=A0=ED=9D=AC=EC=9D=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... \354\230\256\352\270\260\352\270\2602.md" | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 "ShinHeeEul/202504/04 BOJ G4 \355\214\214\354\235\264\355\224\204 \354\230\256\352\270\260\352\270\2602.md" diff --git "a/ShinHeeEul/202504/04 BOJ G4 \355\214\214\354\235\264\355\224\204 \354\230\256\352\270\260\352\270\2602.md" "b/ShinHeeEul/202504/04 BOJ G4 \355\214\214\354\235\264\355\224\204 \354\230\256\352\270\260\352\270\2602.md" new file mode 100644 index 00000000..ee9840fa --- /dev/null +++ "b/ShinHeeEul/202504/04 BOJ G4 \355\214\214\354\235\264\355\224\204 \354\230\256\352\270\260\352\270\2602.md" @@ -0,0 +1,86 @@ +```java +import java.util.*; +import java.io.*; + +class Main { + + + static int[] di = {0,1,1}; + static int[] dj = {1,0,1}; + static boolean[][] map; + static int N; + public static void main(String args[]) throws Exception { + + N = read(); + + map = new boolean[N][N]; + + for(int i = 0; i < N; i++) { + for(int j = 0; j < N; j++) map[i][j] = read() == 1; + } + + long[][][] dp = new long[N][N][3]; + + dp[0][1][0] = 1; + + for(int i = 0; i < N; i++) { + for(int j = 0; j < N; j++) { + int ni = i + 1; + int nj = j + 1; + // 가로로 놓여있을때 + if(check(i, nj, true)) dp[i][nj][0] += dp[i][j][0]; + if(check(ni, nj, false)) dp[ni][nj][2] += dp[i][j][0]; + + // 세로로 놓여있을때 + if(check(ni, j, true)) dp[ni][j][1] += dp[i][j][1]; + if(check(ni, nj, false)) dp[ni][nj][2] += dp[i][j][1]; + + // 대각선으로 놓여있을 때 + if(check(ni, j, true)) dp[ni][j][1] += dp[i][j][2]; + if(check(i, nj, true)) dp[i][nj][0] += dp[i][j][2]; + if(check(ni, nj, false)) dp[ni][nj][2] += dp[i][j][2]; + + } + } + +// for(int i = 0; i < N; i++) { +// for(int j = 0; j < N; j++) { +// System.out.print(dp[i][j][0] + "" + dp[i][j][1] + "" + dp[i][j][2] + " "); +// } +// System.out.println(); +// } +// + System.out.println(dp[N-1][N-1][0] + dp[N-1][N-1][1] + dp[N-1][N-1][2]); + } + + public static boolean check(int i, int j, boolean b) { + if(b)return i >= 0 && j >= 0 && i < N && j < N && !map[i][j]; + return i >= 0 && j >= 0 && i < N && j < N && !map[i][j] && !map[i-1][j] && !map[i][j-1]; + } + + + private static int read() throws Exception { + int c; + int n = 0; + boolean negative = false; + + while ((c = System.in.read()) <= 32) { + if (c == -1) return -1; + } + + if (c == '-') { + negative = true; + c = System.in.read(); + } + + do { + n = n * 10 + (c - '0'); + c = System.in.read(); + } while (c > 32); + + return negative ? -n : n; + } + + +} +```